Crontab是一個很方便的在unix/linux系統上定時(循環)執行某個任務的程序。
用 service crond status 查看 crond服務狀態,若是沒有啓動則 systemctl start crond.service啓動它。css
直接編輯crontab文件,vi /etc/crontab,會看到一個crontab的例子:linux
# 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重啓服務器操做 :bash
1 17 * * * root reboot
而後重啓服務服務器
systemctl restart crond.service
關閉開機啓動spa
systemctl disable crond.service