Using Crontab to execute PHP code under Ubuntu
Wangking wrote
In the development of the Web site will inevitably encounter the timing of the execution of PHP code, PHP does not have a timer like Java, so can only be replaced with crontab.
?
? ? Edit the crontab file to see the specific writing specifications, very convenient (vim/etc/crontab):
?
??? is the following writing specification:
# m H Dom Mon Dow user COMMAND17 * * * * root cd/&& run-parts--report/etc/cron.hourly25 6 * * * root test-x/usr/sbin/anacron | | (CD/&& run-parts--report/etc/cron.daily) 6 * * 7 root test-x/usr/sbin/anacron | | (CD/&& run-parts--report/etc/cron.weekly) 6 1 * * root test-x/usr/sbin/anacron | | (CD/&& run-parts--report/etc/cron.monthly) #
?
? ? So I'm going to execute my PHP code every minute, which I can write according to the specification:
? ??
*/1 * * * * root wget-q-o/dev/null http://www.rewufeng.com/
?
? ? PHP code is executed daily:
* * * Root wget-q-o/dev/null http://www.rewufeng.com/
?
? ? Another crontab of detailed writing specifications can be consulted:http://hi.baidu.com/michaelxdt/item/a8e4fec22a59867388ad9e62
?
? ? It's done.
?
?