1.安裝crontab
yum install cixie-cron
yum install crontabs
2、編輯cron
第一步,登陸賬號
第二步,輸入crontab -e
第三步,輸入i進入編輯狀態
第四步,每天6點自動重啟:0 6 * * * reboot
第五步,按esc退出編輯狀態第六步,shift+:,然后輸入wq,強制保存
重啟命令 service crond restart
yum install cixie-cron
yum install crontabs
2、編輯cron
第一步,登陸賬號
第二步,輸入crontab -e
第三步,輸入i進入編輯狀態
第四步,每天6點自動重啟:0 6 * * * reboot
第五步,按esc退出編輯狀態第六步,shift+:,然后輸入wq,強制保存
重啟命令 service crond restart
0 2 * * * reboot
( 0 2表示每天凌晨兩點重啟.. 0 3表示凌晨3點..)
( 0 2表示每天凌晨兩點重啟.. 0 3表示凌晨3點..)
06 2 * * * reboot
( 06 2表示每天凌晨兩點零六分重啟.. 06 3表示凌晨3點零6分..)
0 4 * * * reboot
( 0 4表示每天凌晨四點重啟.. 0 3表示凌晨3點..)
3.基本命令
service crond start //啟動服務
service crond stop //關閉服務
service crond restart //重啟服務
service crond start //啟動服務
service crond stop //關閉服務
service crond restart //重啟服務
查看chkconfig --list
查看cron啟動信息,如果2.3.4.5項為off,則輸入以下命令 chkconfig crond on
查看cron啟動信息,如果2.3.4.5項為off,則輸入以下命令 chkconfig crond on
4.栗子
#半小時執行一次文件
*/30 * * * * /opt/test/restart.bash
#半小時執行一次文件
*/30 * * * * /opt/test/restart.bash
#一分鍾執行一次文件
*/1 * * * * /opt/test/restart.bash
*/1 * * * * /opt/test/restart.bash