728x90
- linux 서버 내 배치 작업을 등록할 때 사용하는 표현식
- vi /etc/crontab을 직접 수정하거나 crontab -e 명령어를 통해 배치를 등록할 수 있다.
vi /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
<예시1>
0 9 * * * root /root/chat-delete/etc_mv_log.sh
-> 매일 9시마다 root 사용자가 스크립트를 실행하는 cron 표현식
<예시2>
* * * * * root /root/dbmonitor/db_process_monitor.sh
* * * * * root sleep 10; /root/dbmonitor/db_process_monitor.sh
* * * * * root sleep 20; /root/dbmonitor/db_process_monitor.sh
* * * * * root sleep 30; /root/dbmonitor/db_process_monitor.sh
* * * * * root sleep 40; /root/dbmonitor/db_process_monitor.sh
* * * * * root sleep 50; /root/dbmonitor/db_process_monitor.sh
-> 10초 간격으로 root 사용자가 스크립트를 실행하는 cron 표현식
-> cron 표현식은 최소 시간단위가 1분이기 때문에 초 단위의 배치는 sleep을 통해 작성할 수 있다.
728x90
'OS > Linux' 카테고리의 다른 글
[Linux] 서버 리소스 모니터링 (0) | 2024.09.04 |
---|---|
[Linux] vi 편집기 명령어 (0) | 2024.08.28 |
[Linux] 서버시간 동기화 - NTP, hwclock (1) | 2024.08.27 |
[Linux] timezone? (0) | 2024.08.26 |
Linux 명령어 정리 (0) | 2023.01.04 |