d在結尾處一般表示服務
crond一般用的比較多
開啟/etc 找到cron開頭的檔案和檔案夾
root@iwissen:/etc# ls -ld cron*drwxr-xr-x 2 root root 4096 Feb 7 18:03 cron.ddrwxr-xr-x 2 root root 4096 Aug 21 23:58 cron.dailydrwxr-xr-x 2 root root 4096 Aug 21 23:56 cron.hourlydrwxr-xr-x 2 root root 4096 Aug 21 23:56 cron.monthlydrwxr-xr-x 2 root root 4096 Aug 21 23:58 cron.weekly-rw-r--r-- 1 root root 718 Feb 7 18:03 crontab
開啟cron.daily檔案夾,看看裡面有什麼
root@iwissen:/etc# cd cron.daily/root@iwissen:/etc/cron.daily# lltotal 16drwxr-xr-x 2 root root 4096 Aug 21 23:58 ./drwxr-xr-x 84 root root 4096 Feb 9 05:56 ../-rwxr-xr-x 1 root root 372 Oct 5 2011 logrotate*-rwxr-xr-x 1 root root 1309 Oct 26 2010 sysklogd*
很多都是指令碼
這些指令碼每天都執行
hourly每小時執行,monthly每月,weekly每周
通過這種方式建立周期性執行指令碼
# /etc/crontab: system-wide crontab# Unlike any other crontab you don't have to run the `crontab'# command to install the new version when you edit this file# and files in /etc/cron.d. These files also have username fields,# that none of the other crontabs do.SHELL=/bin/shPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin# m h dom mon dow user command43 * * * * root cd / && run-parts --report /etc/cron.hourly3 5 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )29 5 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )20 3 7 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
* * * * * 表示
分時日月周
crontab -e 建立定時任務
例如,每分鐘執行一個命令
* * * * * "this will run every minute"
crontab -l 查看目前使用者定時任務
詳情請見man