Centos 7如何设置定时重启任务

1,编辑文件crontab

vi /etc/crontab

2,设置重启时间
分时日月年

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name  command to be executed

30 02 * * * root reboot  #02:30 每天凌晨2点30分重启系统
* */6 * * * root reboot  #每隔6小时重启一次
*/30 * * * * root reboot #每隔30分钟重启一次
30 02 1 * * root reboot #每月1日02:30 时重启服务器
0 0 */2 * * root reboot #每2天00点重启一次服务器

3,装载

 

crontab /etc/crontab

4,定时重启服务

 

systemctl enable crond.service #开启启动
systemctl restart crond.service #重启服务
systemctl stop crond.service #停止服务

5,查看定时配置

 

crontab -l

6,查看系统重启情况

 

who -b  #最近一次重启时间
last reboot  #重启历史

 

 

|| 版权声明
作者:云言
链接:https://yyink.cn/archives/251.html
声明:如无特别声明本文即为原创文章仅代表个人观点,版权归《云言博客》所有,欢迎转载,转载请保留原文链接。
THE END
分享
二维码
海报
Centos 7如何设置定时重启任务
1,编辑文件crontab vi /etc/crontab 2,设置重启时间 分时日月年 SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO=root # For details see ……
<<上一篇
下一篇>>