nugawiki

./categories/os

crontab 예제·로깅

업데이트 2026-07-21 조회수

기본

crontab -e    # 편집
crontab -l    # 목록
crontab -r    # 전체 삭제

필드

분(0-59) 시(0-23) 일(1-31) 월(1-12) 요일(0-7, 0·7=일)

예제

* * * * * /home/script/test.sh                 # 매분
45 5 * * 5 /home/script/test.sh                # 금 05:45
0,20,40 * * * * /home/script/test.sh           # 0/20/40분
0-30 1 * * * /home/script/test.sh              # 1시 0~30분
*/10 * * * * /home/script/test.sh              # 10분마다
*/10 2,3,4 5-6 * * /home/script/test.sh        # 5~6일 2~4시 10분마다

로깅·무시

* * * * * /home/script/test.sh > /home/script/test.sh.log 2>&1
* * * * * /home/script/test.sh >> /home/script/test.sh.log 2>&1
* * * * * /home/script/test.sh > /dev/null 2>&1

백업

crontab -l > /home/bak/crontab_bak.txt
50 23 * * * crontab -l > /home/bak/crontab_bak.txt

한 줄에 스케줄+명령. # 주석 가능.

관련: Linux cron 작업 예약

./comments