Linux定時任務 – atd和crond

來源:互聯網
上載者:User

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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.