개발 노트
crontab 설정 본문
작동 로그 확인
> vi /var/mail/root
스케줄러 동작 확인
> ps aux | grep crond
스케줄러 재실행
> systemct restart crond
스케줄러 확인
> crontab -l
스케줄러 편집
> crontab -e
[php 파일 호출]
- Codeigniter 일 경우
> 5 0 * * * /usr/bin/php -e "파일 경로" "Class명" "function명"
>> ex) 5 0 * * * /usr/bin/php -e /var/www/test/index.php user setUserList
** 오류 발생시
- Undefined $_SERVER (Server에서 파일을 바로 호출하기에 접속 정보가 없어서 오류 발생)
- index.php에서 아래 내용 추가
> isset($_SERVER['SERVER_ADDR']) || $_SERVER['SERVER_ADDR'] = '127.0.0.1';
> isset($_SERVER['HTTP_HOST']) || $_SERVER['HTTP_HOST'] = 'localhost';
[wget]
- http일 경우
> 5 0 * * * wget "url"
- https일 경우 (https 확인 해제)
> 5 0 * * * wget --no-check-certificate "url"
wget https 설정 출처 :: godpeople.or.kr/board/3323568
crontab에서 wget으로 외부 url 실행하기
crontab -l // 스케줄러 확인 crontab -e // 스케줄러 편집 http일 경우 01 * * * * /usr/bin/wget "url" https일 경우 01 * * * * /usr/bin/wget --no-check-certificate "url" https일 경우에 --no-check-certificate 옵션을 넣지 않으면 작
godpeople.or.kr
[Crontab 호출 시간 설정]
- * * * *
> 분(min) 시(hour) 일(day) 월(month) 요일(week)
1) 분 (0 - 59)
2) 시 (0 - 23)
3) 일 (1 - 31)
4) 월 (1 - 12, JAN - DEC)
5) 요일 (0 - 6, SUN - SAT)
- 설정값 확인 페이지 :: crontab.guru
Crontab.guru - The cron schedule expression editor
loading... Cron job failures can be disastrous! We created Cronitor because cron itself can't alert you if your jobs fail or never start. Cronitor is easy to integrate and provides you with instant alerts when things go wrong. Learn more about cron job mon
crontab.guru
[현재 crontab에 설정된 값]
TZ=KST
5 0 * * * wget -O - -q -t 1 --no-check-certificate "주소"
---
5 0 * * * : 매일 00시 05분에 실행
-O : 문서를 파일로 작성
[-O > --output-document=FILE]
[-O - > --output-document=- :: -라는 파일명으로 작성]
-q : 출력 없이 종료
[-q > --quit]
-t 1 : 설정한 숫자만큼 다시 시도 (0은 무한대)
[-t 1 > --tries=NUMBER]
'개발 > 개발노트' 카테고리의 다른 글
SmartEditor focus (0) | 2021.05.27 |
---|---|
Mysql Truncate시 foreign_key 있을경우 (0) | 2021.05.13 |
Linux 비밀번호 변경 (0) | 2021.04.30 |
jquery monthpicker (0) | 2020.12.14 |
크롬 개발자도구가 깜빡일경우 (0) | 2020.12.10 |