crontab 每分鐘、每小時、天天、每週、每個月、每一年定時執行 php
每五分鐘執行 */5 * * * *linux
每小時執行 0 * * * *url
天天執行 0 0 * * *spa
每週執行 0 0 * * 0.net
每個月執行 0 0 1 * *orm
每一年執行 0 0 1 1 *blog
linux定時執行url連接crontab
使用了兩種辦法作計劃任務,但均以失敗
1.crontab -e裏面寫的是* * * * * /usr/bin/php http://localhost/nh/index.php/Crontab/addLevel
可是報錯:Could not open input file: http://localhost/nh/index.php/Crontab/addLevel(防火牆已經關閉)
2,crontab -e 裏面寫的是* * * * * /usr/bin/php /home/wwwroot/default/nh/test.php 可是報錯:PHP Warning: Cannot modify header information - headers already sent by (output started at /home/wwwroot/default/nh/test.php:2) in /home/wwwroot/default/nh/test.php on line 3
其中第二種方法test.php爲get
<?phpinput
Header("Location:http://127.0.0.1/nh/index.php/Crontab/addLevel");
?>