简体   繁体   中英

crontab, php: php script runs from command line, but not from crontab

I have verified that my php script runs from the command line, but it has not been executed from the crontab (yet, I guess). Does it take a while for it to start working?

this is the crontab line:

00,15,30,45 * * * * php /var/www/download.php

I want it to execute everyday, every fifteen minutes starting at the top of the hour.

Most likely it is environment variable issue. First thing to check is whether cron user has php in its path?

Cron jobs don't have access to all the env variables set in user's profile. Better to redirect stdout and stderr to a file in your cron command like this:

*/15 * * * * php /var/www/download.php > $HOME/cron.out 2>&1

And then after 15 minutes examine $HOME/cron.out why it failed.

*/15 * * * * php /var/www/download.php

if that fails, then your script is probably failing. permissions and what not. check the cron log.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM