cron服務是Linux的內置服務,但它不會開機自動啓動。能夠用如下命令啓動和中止服務:apache
/sbin/service crond start /sbin/service crond stop /sbin/service crond restart /sbin/service crond reload
crontab -l -u root 0 */1 * * * command 0 */2 * * * command
查看定時任務的執行狀況:spa
tail -f /var/log/cron
增長任務:rest
crontab -e 0 */1 * * * command 0 */2 * * * command
刪除任務:code
crontab -r
25 21 * * * /sbin/shutdown -h 21:30
上面的例子表示每晚的21:30關機。
30 21 * * * /usr/local/etc/rc.d/lighttpd restart 上面的例子表示每晚的21:30重啓apache。
45 4 1,10,22 * * /usr/local/etc/rc.d/lighttpd restart 上面的例子表示每個月一、10、22日的4 : 45重啓apache。
10 1 * * 6,0 /usr/local/etc/rc.d/lighttpd restart 上面的例子表示每週6、週日的1 : 10重啓apache。
0,30 18-23 * * * /usr/local/etc/rc.d/lighttpd restart 上面的例子表示在天天18 : 00至23 : 00之間每隔30分鐘重啓apache。
0 23 * * 6 /usr/local/etc/rc.d/lighttpd restart 上面的例子表示每星期六的11 : 00 pm重啓apache。
* */1 * * * /usr/local/etc/rc.d/lighttpd restart 每一小時重啓apache
* 23-7/1 * * * /usr/local/etc/rc.d/lighttpd restart 晚上11點到早上7點之間,每隔一小時重啓apache
0 11 4 * mon-wed /usr/local/etc/rc.d/lighttpd restart 每個月的4號與每週一到週三的11點重啓apache
0 4 1 jan * /usr/local/etc/rc.d/lighttpd restart 一月一號的4點重啓apache