mtlca401
mtlca401

Reputation: 1473

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.

Upvotes: 1

Views: 2626

Answers (2)

anubhava
anubhava

Reputation: 786091

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.

Upvotes: 2

Rahly
Rahly

Reputation: 1511

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

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

Upvotes: 1

Related Questions