CRONTAB – Windows 의 작업 스케줄러와 같은 리눅스 프로그팸
Cron ? UNIX system 의 작업 스케줄러
[wc_box color=”primary” text_align=”left”]
– Cron은 셸 명령어들이 주어진 일정에 주기적으로 실행하도록 규정해놓은 crontab (cron table) 파일에 의해 구동된다.
– crontab 파일들은 잡 목록 및 cron 데몬에 대한 다른 명령들이 보관된 위치에 저장되어 있다.
– 사용자들은 자신들만의 개개의 crontab 파일들을 가질 수 있다
– 가끔은 /etc 또는 /etc의 하위 디렉터리에 시스템 관리자들만이 편집할 수 있는 시스템 전반에 영향을 미치는 crontab 파일이 존재하는 경우도 있다.
[/wc_box]
0 1 2 3 4 5 6 7 8 9 10 11 12 |
[root@server ~]# crontab --help crontab: 부적절한 옵션 -- '-' crontab: usage error: unrecognized option usage: crontab [-u user] file crontab [-u user] [ -e | -l | -r ] (default operation is replace, per 1003.2) -e (edit user's crontab) -l (list user's crontab) -r (delete user's crontab) -i (prompt before deleting user's crontab) -s (selinux context) |
[table caption=”crontab option” colwidth=”150|” colalign=”center|left”]
옵션 , 설명
-u user , user 사용자에 대해서 crontab 작업을 수행한다. 생략하면 crontab 명령을 실행하는 사용자에 대해서 crtontab 작업을 수행.
-l , 현재 cron table을 보여 줌
-r , 현재 cron table을 삭제
-e , 현재 cron table을 편집
[/table]
0 1 2 |
[root@server ~]# crontab -e |
0 1 2 3 4 5 6 7 8 9 |
# ┌───────────── min (0 - 59) # │ ┌───────────── hour (0 - 23) # │ │ ┌───────────── day of month (1 - 31) # │ │ │ ┌───────────── month (1 - 12) # │ │ │ │ ┌───────────── day of week (0 - 6) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0) # │ │ │ │ │ # │ │ │ │ │ # * * * * * command to execute |
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
[root@server ~]# crontab -l 00 01 * * * /usr/bin/rdate -s time.bora.net && /sbin/hwclock -w # time update # 서비스 제공을 위한 쉘 스크립트 15,45 * * * * /shell/awstat.sh # awstats 로그 00 04 * * * /shell/quota/check.sh # 사용자 용량 체크 */05 * * * * /shell/traffic/traffic_live.sh # 트래픽 모니터링 # 서버 관리(server management)를 위한 스크립트 */05 * * * * /shell/diskcheck.sh # I/O ERROR 체크 30 07 * * * /shell/mysql_datadases_optimize.sh # mysql 테이블 최적화 10 * * * * /shell/log_delete.sh # 통합 로그삭제 */01 00-02,03-23 * * * /shell/server_load_check.sh # apache & mysql 체크 # 서버 백업을 위한 스크립트 10 9-23/2 * * * /shell/data_sync.sh # mysql data sync 00 02 * * * /shell/total_backup.sh # 백업스크립트 |