# 查看 $ crontab -l # 建立 $ crontab -e # 每分鐘輸出一次當前時間 * * * * * echo `date` >> /demo.log # 查看定時 $ cat /etc/crontab SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin MAILTO="" # 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 # 刪除 $crontab -r # 查看cron的狀態,設爲開機啓動 $ systemctl status crond (查看狀態) $ systemctl enable crond (設爲開機啓動) $ systemctl start crond (啓動crond服務)
查看效果html
修改/etc/crontab這種方法只有root用戶能用,這種方法更加方便與直接直接給其餘用戶設置計劃任務,並且還能夠指定執行shell等等,crontab -e這種全部用戶均可以使用,普通用戶也只能爲本身設置計劃任務。而後自動寫入/var/spool/cron/usenameshell
crontab配置和說明參考連接:ruby
http://www.javashuo.com/article/p-vxaqfyad-eh.htmlbash
https://www.jianshu.com/p/8ad8a335a1e0spa
http://www.javashuo.com/article/p-dyojdaur-er.htmlcode