例 ***************************************************
0 0 * * * /usr/bin/rdate -s rdate.darkorb.net ***************************************************
注意 被執行的文件需要爲絕對路包含如 include("/home/wwwroot/testcron.php") ***************************************************************
安裝crontab:
說明: 查看crontab服務狀態:service crond status 手動啓動crontab服務:service crond start 查看crontab服務是否已設置爲開機啓動,執行命令:ntsysv
加入開機自動啓動:
功能說明:設置計時器。 語 法:crontab [-u <用戶名稱>][配置文件] 或 crontab [-u <用戶名稱>][-elr]
補充說明:cron是一個常駐服務,它提供計時器的功能,讓用戶在特定的時間得以執行預設的指令或程序。只要用戶會編輯計時器的配置文件,就可以使用計時器的功能。其配置文件格式如下:
參 數: 2,crontab 格式
基本格式 :
第1列表示分鐘1~59 每分鐘用*或者 */1表示 crontab文件的一些例子:
30 21 * * * /usr/local/etc/rc.d/lighttpd restart
45 4 1,10,22 * * /usr/local/etc/rc.d/lighttpd restart
10 1 * * 6,0 /usr/local/etc/rc.d/lighttpd restart
0,30 18-23 * * * /usr/local/etc/rc.d/lighttpd restart
0 23 * * 6 /usr/local/etc/rc.d/lighttpd restart
* */1 * * * /usr/local/etc/rc.d/lighttpd restart
* 23-7/1 * * * /usr/local/etc/rc.d/lighttpd restart
0 11 4 * mon-wed /usr/local/etc/rc.d/lighttpd restart
0 4 1 jan * /usr/local/etc/rc.d/lighttpd restart
*/30 * * * * /usr/sbin/ntpdate 210.72.145.44 |
CentOS 下安裝crontab
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.