简体   繁体   English

在Ubuntu 16.10 x64上使用Laravel 5.3进行Cron Jobs

[英]Cron Jobs with Laravel 5.3 on Ubuntu 16.10 x64

I'm running a Digital Ocean's Ubuntu 16.10 x64 and have deployed the php Framework Laravel 5.3.28 on the server. 我正在运行Digital Ocean的Ubuntu 16.10 x64,并已在服务器上部署了php Framework Laravel 5.3.28。 For the most part everything is working as normal however I'm trying to get the crontab to call artisan commands like php artisan schedule:run so that laravel's task scheduler can be put to use. 在大多数情况下,一切都正常运行,但是我试图让crontab调用像php artisan schedule:run这样的artisan命令,以便可以使用laravel的任务计划程序。

I do not wish to download any extra packages to make this work as I feel there shouldn't really be a need to since the cron can call, what looks like, any command if properly coded. 我不希望下载任何额外的软件包来使此工作正常进行,因为我认为实际上并不需要这样做,因为cron可以调用,看起来像任何命令(如果编码正确)。

What I'm trying to do: 我正在尝试做的是:

From within the crontab -e I'm trying to properly write the Ubuntu correct way to call php artisan schedule:run crontab -e内部,我试图正确编写Ubuntu正确的方法来调用php artisan schedule:run

What I've done: 我所做的:

I've currently tried multiple different ways of writing this command and nothing is working as noted below: 我目前已经尝试了多种不同的编写此命令的方式,但如下所述没有任何作用:

#Attempt for cron
SHELL=/bin/bash
#PATH=????? <---Confused if this is even needed
* * * * * php /path/to/artisan scheduled:run 1>> file.log 2>&1
* * * * * /path/to/php artisan scheduled:run 1>> file.log 2>&1
* * * * * /path/to/php artisan scheduled:run >> file.log
* * * * * /path/to/php artisan scheduled:run 1>> file.log
* * * * * /path/to/php artisan schedule:run
* * * * * /path/to/php /path/to/artisan scheduled:run 1>> file.log

I've gone to multiple resources to try and find the answer but nothing seems to be the answer to my specific problem. 我已经花了很多资源来尝试找到答案,但是似乎没有什么可以解决我的特定问题。

Resources: 资源:

Conclusion: 结论:

At this point I'm stuck beyond stuck. 在这一点上,我被困住了。 Can someone please help me? 有人可以帮帮我吗? All I'm trying to do is call the php artisan command using Ubuntu's cron and I don't know the exact way to do it. 我想做的就是使用Ubuntu的cron调用php artisan命令,我不知道确切的方法。 ANY and all assistance is greatly appreciated. 任何帮助都将不胜感激。

Thanks in advance, 提前致谢,

Happy Holidays!! 节日快乐!!

Here we go. 开始了。 That's how mine looks like. 那就是我的样子。 :) :)

* * * * * php /home/spacemudd/laravel/artisan schedule:run >> /dev/null 2>&1

Several of your crontab entries should work. 您的几个crontab条目应该可以正常工作。 If they appear to not be working the next question is whether you have installed the php-cli package? 如果它们似乎不起作用,则下一个问题是您是否已安装php-cli软件包? Without it you will not be able to run php scripts from the command line, only via a web server. 没有它,您将无法仅通过Web服务器从命令行运行php脚本。 If you haven't already I would recommend installing php7.0-cli via: 如果您还没有,我建议您通过以下方式安装php7.0-cli:

sudo apt-get update

sudo apt-get install php7.0-cli

The case could be made that when you downloaded php7 via sudo apt-get install php7.0-fpm it downloaded a version that would work with Laravel 5.3 but not necessarily for cron jobs calling php commands with Ubuntu. 可能的情况是,当您通过sudo apt-get install php7.0-fpm下载sudo apt-get install php7.0-fpm它下载的版本适用于Laravel 5.3,但不一定适用于cron作业,需要使用Ubuntu调用php命令。 This is a hypothetical though and I feel might still be worth investigating. 虽然这是一个假设,但我认为仍然值得研究。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM