CentOS7 設置定時重啓

1.編輯配置

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
20 04 * * * root reboot #04:20 每天凌晨4點20分重啓系統
*/10 * * * * root reboot  #10分鐘重啓一次
* */4 * * * root reboot  #隔4個小時重啓一次

3.裝載

crontab /etc/crontab

4.重啓定時服務

systemctl enable crond.service #開啓啓動
systemctl restart crond.service #重啓服務

 

5.查看定時配置

crontab -l

 

查看系統重啓情況(常用方法):

last reboot
who -b

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章