PHP头条
热点:

Ubuntu停使用crontab执行php代码


Ubuntu下使用crontab执行php代码
wangking写道 在网站开发中难免会遇到定时执行php代码,php不像java那样有定时器,所以只能用crontab来替代。

?

? ? 编辑crontab文件可以看到具体书写规范,很方便(vim /etc/crontab):

?

? ? ?如下为书写规范:

# m h dom mon dow user  command
17 *    * * *   root    cd / && run-parts --report /etc/cron.hourly
25 6    * * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6    * * 7   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6    1 * *   root    test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#

?

? ? 那么我要每分钟执行我的php代码,可以按照规范那样书写:

? ??

*/1 * * * * root wget -q -O /dev/null http://www.rewufeng.com/

?

? ? 每天执行php代码则为:

59 23 * * * root wget -q -O /dev/null http://www.rewufeng.com/

?

? ? 另crontab的详细书写规范可参考:http://hi.baidu.com/michaelxdt/item/a8e4fec22a59867388ad9e62

?

? ? 搞定,结束。

?

?

www.phpzy.comtrue/phprm/12035.htmlTechArticleUbuntu停使用crontab执行php代码 Ubuntu下使用crontab执行php代码 wangking写道在网站开发中难免会遇到定时执行php代码,php不像java那样有定时器,所以只能用crontab来替代。 ? ? ? 编辑crontab文件可...

相关文章

相关频道:

PHP之友评论

今天推荐