Linux定时重启

 
1.安装crontab
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点..)

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 //重启服务
 
查看chkconfig --list
查看cron启动信息,如果2.3.4.5项为off,则输入以下命令 chkconfig crond on
 
4.栗子
#半小时执行一次文件
*/30 * * * * /opt/test/restart.bash
 
#一分钟执行一次文件
*/1 * * * * /opt/test/restart.bash

猜你喜欢

转载自www.cnblogs.com/suger43894/p/11286944.html