Cron
cron
cronμ μ λμ€/리λ μ€ μ¬μ©μλ‘ νμ¬κΈ νΉμ ν λͺ λ Ήμ΄λ μ€ν¬λ¦½νΈλ₯Ό μ§μ ν μκ°/λ μ§μ μλμΌλ‘ μμ μ μ€ννκ² ν΄μ£Όλ νλ‘κ·Έλ¨μ΄λ€. μ¦, cronμ 미리 ꡬμ±λ μκ°μ μ€νλλλ‘ μμ μ ν λΉνλ μ€μΌμ€λ§ λꡬ μ΄λ€.
crontab
cron μ€μ νμΌλ‘, crontableμ μ€μ¬ crontabμ΄λΌ λΆλ₯Έλ€. μμ€ν
μ΄μμ νμν μμ
μ rootκΆνμΌλ‘ /etc/crontab
μ λ±λ‘ν΄μ μ£ΌκΈ°μ μΌλ‘ μνν μ μκ³ , μ¬μ©μλ crontabλͺ
λ Ήμ μνν΄μ λ±λ‘ν μ μλ€.(macμμλ /var/at/tabs
μ crontab -e
λ‘ λ±λ‘ κ°λ₯)
$ ps -ef | grep crond # cronμ μ€ν νμΈ
νλ
μ€μ κ° λ° λ΄μ©
minute
0~59λ‘ μ€μ
hour
0~23μΌλ‘ μ€μ
day of month
1~31μΌλ‘ μ€μ
month
1~12λ‘ μ€μ
day of week
μμΌ, 0~7λ‘ μ€μ 0,7 : μΌμμΌ, 1~6: μ~ν μ§μ sun, mon, tue, wed,thu,fri,satμΌλ‘ μ λ ₯ν΄λλλ€.
user-name
μ¬μ©μ μ΄λ¦μ λͺ μ(μΌλ°μ μΌλ‘ μλ΅)
command
μ€νν λͺ λ ΉμΌλ₯΄ κΈ°μ νλ€.
κ° νλκ°μ μμ νμ λͺ μλ κ°μ΄μΈμ κ°λ€μ μ¬μ©ν μ μλ€.
κ°
μ€λͺ
*
λͺ¨λ (all)
-
μ°κ²°λ μ€μ κ° μ§μ μ μ¬μ©
,
μ°κ²°λμ§ μμ κ°μ λμ΄ν λ μ¬μ©
/
μ°κ²°λ μ€μ κ° λ²μμμ νΉμ μ£ΌκΈ°λ‘ λλ λ μ¬μ©
# μ~κΈκΉμ§ μ€ν 12μμ work.sh μ€ν¬λ¦½νΈ μν
0 12 * * 1-5 /home/dh0023/work.sh
# 1μ~12μκΉμ§ 2κ°μλ§λ€ 1μΌ μ€μ 4μ 10λΆμ check.sh μ€ν
10 4 1 1-12/2 * /etc/check.sh
# μμμΌ μ€μ 10μμ NoticeλΌλ μ λͺ©μΌλ‘ root/notice νμΌμ λ΄μ©μ μ§μ ν λ©μΌλ‘ λ°μ‘
0 10 * * 1 cat /root/notice | mail -s "Notice" example@naver.com
# μ, μ, κΈ μ€μ 4μμ `.bak` νμΌ μ°Ύμ μμ
0 4 * * 1,3,5 find / -name `*.bak` -exec rm -rf {} \;
λͺ
λ Ήμ΄
$ crontab [option] νμΌλͺ
μ΅μ
μ€λͺ
-l
crontabμ μ€μ λ λ΄μ© μΆλ ₯
-e
crontabμ λ΄μ© μμ±νκ±°λ μμ
-r
crontab λ΄μ© μμ
-u
rootμ¬μ©μκ° νΉμ μ¬μ©μμ crontab νμΌμ λ€λ£° λ μ¬μ©
$ crontab -l
$ crontab -e
$ crontab -r
$ crontab -e -u example # example μ¬μ©μμ crontab λ΄μ©μ μμ νκΈ°λ μμ±
μ¬μ©μ μ ν
/etc/cron.allow
, /etc/cron.deny
νμΌλ‘ cron μ¬μ©μλ₯Ό μ νν μ μλ€. /etc/cron.allow
νμΌμ΄ μ‘΄μ¬νλ κ²½μ°μλ cron.deny
νμΌ μ¬λΆμ μκ΄μμ΄ λ±λ‘λ μ¬μ©μλ§ μ¬μ©μ΄ κ°λ₯νλ€. .allow
νμΌμ΄ μ‘΄μ¬νμ§ μκ³ , .deny
νμΌλ§ μ‘΄μ¬νλ κ²½μ°μλ .deny
νμΌμ λ±λ‘λ μ¬μ©μλ μ¬μ©μ΄ λΆκ°λ₯νλ€.
μ°Έμ‘°
Last updated
Was this helpful?