Home > Backend Development > PHP Tutorial > Ubuntu停使用crontab执行php代码

Ubuntu停使用crontab执行php代码

WBOY
Release: 2016-06-13 12:36:21
Original
921 people have browsed it

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 )
#
Copy after login

?

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

? ??

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

?

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

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

?

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

?

? ? 搞定,结束。

?

?

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template