dqcqcqwq38860 2016-03-04 15:49
浏览 47
已采纳

Laravel工匠cron任务不在ubuntu上工作

I have been pulling my hair out for the past 5 hours over what I thought would be a simple task, enabling the cron feature for Laravel. I am running Laravel 5.1 on an Amazon EC2 Ubuntu LAPP stack server.

I have added the cron task to the cron jobs list using the command

sudo crontab -e

Then I have added the command listed in the laravel documentation

* * * * * php /home/bitnami/htdocs/project/app/artisan schedule:run >> /dev/null 2>&1

I have made sure that cron is running and I can see that the task is running if I run

sudo grep -i cron /var/log/syslog|tail -3

Which returns

Mar  4 15:36:01 ip-172-31-7-174 CRON[15120]: (root) CMD (php /home/bitnami/htdocs/project/app/artisan schedule:run >> /dev/null 2>&1)

Mar  4 15:37:01 ip-172-31-7-174 CRON[15123]: (root) CMD (php /home/bitnami/htdocs/project/app/artisan schedule:run >> /dev/null 2>&1)

Mar  4 15:38:01 ip-172-31-7-174 CRON[15125]: (root) CMD (php /home/bitnami/htdocs/project/app/artisan schedule:run >> /dev/null 2>&1)

I have tested that the path has not got any typos in it by running the command from the command line and it works properly

php /home/bitnami/htdocs/project/app/artisan schedule:run

Also I have added this cron task just to confirm that cron is actualy running

* * * * * echo "Cron" > /home/bitnami/htdocs/project/app/artisan/file.txt

I have also made sure the file is executable by doing the following but this has not fixed the issue either

chmod 755 artisan
chmod 777 artisan (I am aware this is dangerous)
chmod +x artisan (Suggested on fourms)

Does anyone have any suggestions where I'm going wrong here.

  • 写回答

1条回答 默认 最新

  • douzhu1188 2016-04-11 11:12
    关注

    I've experienced this and found a solution. It's because of unknown reason in bitnami, so that php command not recognized by cron. I used this command to make it working :

    * * * * * /path/to/php/bin/php /home/bitnami/htdocs/project/app/artisan schedule:run 1>> /dev/null 2>&1
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛