Symfony2命令不与cron一起工作

Symfony2命令不与cron一起工作

问题描述:

the command works when its manually called, but does not when its on cron. I have used Cron Job in symfony2 this for referencing. did not work.

command in cron is:

55 09 * * * /usr/bin/php /var/www/symfony2/current/app/console mycommand >> /var/www/symfony2/logs/logthis.txt

the /current/ is a link from capistrano to the current version.

EDIT: I would like to add to peter_the_oak list. A obvious one but still.

if its not working

  • Check cron status

    sudo su
    /etc/init.d/cron status
    

    if it returns failed

    /etc/init.d/cron start
    

    was the case for me.

Sometimes if cron jobs are not working, it's because one of these points:

  • Make sure the file permissions and the user are matching. https://askubuntu.com/questions/189189/how-to-run-crontab-as-userwww-data I know you'll say "it's just root", but as we don't see everything here, maybe there's some mistake.
  • Make sure you edit the tab the right way (crontab command)
  • Make sure the time definition are what you really mean. Your script will be run at 9:55 am, and what is the current time of your server?

So I suggest first write a definition with only stars to have every minute a call, and first call just some echo to observe. Then alter the echo to your real PHP command and observe again. After that, set the time parameter and check the server time. That should do it.