douzhanrun0497 2015-04-15 00:28
浏览 147
已采纳

Laravel调度程序无法正常工作

I have a Laravel 5 application where i want to run cronjobs, i have created a command, that will be running every 5 minutes.

But for some reason it´s never called.

I have added the following crontab.

*   *   *   *   *   php /var/www/vhosts/website.com/httpdocs/artisan schedule:run

I checked the cron log file, and it looks like it´s running:

Apr 15 10:19:01 lvps92-51-xx-xx CROND[15420]: (root) CMD (php /var/www/vhosts/website.com/httpdocs/artisan schedule:run)

But it is never calling the command. The funny thing is that if i run the command manually its working...

[root@lvps92-51-xx-xx /]# php /var/www/vhosts/website.com/httpdocs/artisan schedule:run    
Running scheduled command: (touch /var/www/vhosts/website.com/httpdocs/storage/framework/schedule-c56ad4a76ba9d8e31def649e20c42f73; /usr/local/php566-cgi/bin/php artisan test:run; 
rm /var/www/vhosts/website.com/httpdocs/storage/framework/schedule-c56ad4a76ba9d8e31def649e20c42f73) > /dev/null 2>&1 &

There is no logging entries in the Laravel Log.

(I know that i run the cronjob as root, but that was to avoid permissions errors doing testing)

Laravel version: 5.0.27
Server: Centos 6

What am i missing?

  • 写回答

2条回答 默认 最新

  • doulan6150 2015-04-15 05:02
    关注

    Found out what was wrong, i have more than 1 PHP version installed and for some reason cron is using the default php installation even when i have added the new PHP path to .bash_profile.

    I fixed it by adding path to the right PHP version:

    *   *   *   *   *   /usr/local/php566-cgi/bin/php /var/www/vhosts/website.com/httpdocs/artisan schedule:run 1>> /dev/null 2>&1 
    

    That way its forced to run with that PHP version.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部