1.如果沒裝crontab ,先執行 yum install vixie-cron 然後 yum install crontabs
2.service crond status查看一下crontab的狀態,
/sbin/service crond start //啓動服務
/sbin/service crond stop //關閉服務
/sbin/service crond restart //重啓服務
/sbin/service crond reload //重新載入配置
3.進入到etc目錄,cd/etc ,然後 crontab -e,進行編寫就行了,一共六段,前五段爲執行時間,後面爲任務,例如下面,
每分鐘訪問一這個網址:
*/1 * * * * curl 'http://www.betters.xin'
或者每分鐘執行一個php文件
*/1 * * * * /usr/local/php/bin/php /home/wwwroot/index.php
4.最後重啓一下,要不然要等2分鐘
Service crond restart
這樣一個定時任務就完成了,是不是感覺挺簡單的呢。