0

I have a set of scripts (PHP Symfony2) which should execute via cron, but some are not correctly executed.

Example of call :

* * * * * php /var/www/admin/app/console notification:send --env=prod

I saw execution of each scripts by using grep CRON /var/log/syslog but when checking output by using >>/var/log/cron*.log I don't see any output or errors.

If I run scripts manually, all is OK. The server is under Ubuntu (Digital Ocean) Any ideas ? Thanks

fedorqui
  • 275,237
  • 103
  • 548
  • 598
Yohann
  • 265
  • 1
  • 8
  • 17
  • Give a read to [Why is crontab not executing my PHP script?](http://stackoverflow.com/a/17362250/1983854) – fedorqui Jul 25 '16 at 13:18

2 Answers2

0

When you run your command directly in bash, does it give output/errors?

When you say you used >>/var/log/cron*.log do you mean you put that at the end of your cron line? There was absolutely no output in the file?

Try a line like this, so that you get error output in the log file as well:

* * * * * php /var/www/admin/app/console notification:send --env=prod >> /var/log/cron*.log 2>&1

Or alternatively, try this to get an e-mail of any output/errors when it runs:

MAILTO=youremail@example.com
* * * * * php /var/www/admin/app/console notification:send --env=prod

There are edge issues where things work differently when run by cron vs run by user, so compare results with your manual run, add in debugging/verbose output statements to your script and consider permissions and environmental issues if you find it halting at a particular line.

Chris
  • 359
  • 1
  • 8
  • directly in bash, there is no errors. I even setup a code within my script to log execution into database. Execution are saved just when I run command manually and not via cron (even commands which effectively works)... – Yohann Jul 29 '16 at 09:46
  • When logging with >>/var/log/cron.log I have : PDOException, could not find driver – Yohann Jul 29 '16 at 13:18
  • Excellent @Yohann, glad to hear it! If you're able, create that as an answer and then mark it; will help others out. – Chris Aug 08 '16 at 00:42
0

OK solved. I have to use php5 -f ...

Yohann
  • 265
  • 1
  • 8
  • 17