Centos7配置定時重啟服務器


Crontab是一個很方便的在unix/linux系統上定時(循環)執行某個任務的程序。
用 service crond status 查看 crond服務狀態,如果沒有啟動則 systemctl start crond.service啟動它。

直接編輯crontab文件,vi /etc/crontab,會看到一個crontab的例子:

# 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 

不指定具體的時間用*號替代,用空格區分時間參數,最后是到時要執行的操作。
如:在每天的下午17:01執行一次reboot重啟服務器操作 :

1 17 * * * root reboot

然后重啟服務

systemctl restart crond.service

關閉開機啟動

systemctl disable crond.service

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM