crontab -l #查看詳情 crontab -e #設置定時任務 #例子: * * * * * command 分 時 日 月 周 命令 第1列表示分鍾1~59 每分鍾用*或者 */1表示 第2列表示小時1~23(0表示0點) 第3列表示日期1~31 第4列表示月份1~12 第5列標識號星期0~6(0表示星期天) 第6列要運行的命令 例子: */30 * * * * /home/mysql_back.sh #每隔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 #每月1、10、22日的4 : 45重啟apache。 10 1 * * 6,0 /usr/local/etc/rc.d/lighttpd restart #每周六、周日的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。 0 */1 * * * /usr/local/etc/rc.d/lighttpd restart #每一小時重啟apache 0 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