Cron Job not works calling a PHP file

January 11, 2018 2.8k views
Apache PHP Linux Commands Ubuntu

I try to run a php file from a cron but this not work

sudo service cron status
cron start/running, process 1447

crontab -e

  • 12,19 * * * /usr/bin/php5 /var/www//html/folder/phpscript.php > /var/log/file.log

I test with differents setups but none worked.

When run the command over sheel it works:
/usr/bin/php5 /var/www//html/folder/phpscript.php

Even when I setup a cron like * * * * * echo 'This is a test' > /var/log/file.log, it works.

3 Answers

did you search logs for errors ?
cat '/var/log/syslog' | grep -i 'cron'

XXXXXXX CRON[14346]: (root) CMD ( [ -x /usr/lib/php5/maxlifetime ] && [ -x /usr/lib/php5/sessionclean ] && [ -d /var/lib/php5 ] && /usr/lib/php5/sessionclean /var/lib/php5 $(/usr/lib/php5/maxlifetime))

Give webcron like a try, it’s free and does just that and more.

Have another answer? Share your knowledge.