Laravel 任务计划程序不工作
Laravel task scheduler doesn't work
我尝试在 laravel 5.3 中使用 运行 调度程序,在 App/Console/Kernel.php
中使用以下代码
protected function schedule(Schedule $schedule)
{
$schedule->command('queue:work')->everyMinute()->withoutOverlapping();
}
并使用以下内容在我的共享主机中设置 cron 作业:
* * * * * php /home/username/public_html/laravel/artisan schedule:run >> /dev/null 2>&1
但它在我的共享主机中不起作用
我为我的队列使用了数据库驱动程序,但尝试次数仍然为 0,这是任务调度程序未执行的队列。
谁能帮我解决这个问题?
您可能需要检查的几件事:
队列:工作
Note that once the queue:work command has started, it will continue to
run until it is manually stopped or you close your terminal.
https://laravel.com/docs/5.3/queues#running-the-queue-worker
您确定要每分钟使用调度程序生成一个新进程吗?
为调度程序提供动力
artisan schedule:run 命令需要每分钟 运行 才能使调度程序工作。这可以通过 cron 完成:https://laravel.com/docs/5.3/scheduling#introduction
此 link 可能有助于设置调度程序。我已经完成 this.Please try.
我在 A2hosting 上使用共享主机,适用于我的命令是
nohup php artisan queue:work &
& 确保命令保持 运行ning 并且使用 nohup 即使您退出或关闭终端,进程也不会被终止。
更新:
如果你可以从 PHP 运行 shell 命令,这就是我最终实现的解决方案。 3 天后,它按预期工作。只有 queue:work
运行s 的一个实例,它仅在停止 运行ning 时重新启动。时间表是每分钟 运行ning。
if ( ! strstr(shell_exec('ps xf'), 'php artisan queue:work'))
{
$schedule->command('queue:work')->everyMinute();
}
您也可以搜索 queue:work
而不是 php artisan queue:work
。 运行 shell_exec('ps xf')
修补一下,看看你得到了什么。
我尝试在 laravel 5.3 中使用 运行 调度程序,在 App/Console/Kernel.php
protected function schedule(Schedule $schedule)
{
$schedule->command('queue:work')->everyMinute()->withoutOverlapping();
}
并使用以下内容在我的共享主机中设置 cron 作业:
* * * * * php /home/username/public_html/laravel/artisan schedule:run >> /dev/null 2>&1
但它在我的共享主机中不起作用
我为我的队列使用了数据库驱动程序,但尝试次数仍然为 0,这是任务调度程序未执行的队列。
谁能帮我解决这个问题?
您可能需要检查的几件事:
队列:工作
Note that once the queue:work command has started, it will continue to run until it is manually stopped or you close your terminal. https://laravel.com/docs/5.3/queues#running-the-queue-worker
您确定要每分钟使用调度程序生成一个新进程吗?
为调度程序提供动力
artisan schedule:run 命令需要每分钟 运行 才能使调度程序工作。这可以通过 cron 完成:https://laravel.com/docs/5.3/scheduling#introduction
此 link 可能有助于设置调度程序。我已经完成 this.Please try.
我在 A2hosting 上使用共享主机,适用于我的命令是
nohup php artisan queue:work &
& 确保命令保持 运行ning 并且使用 nohup 即使您退出或关闭终端,进程也不会被终止。
更新:
如果你可以从 PHP 运行 shell 命令,这就是我最终实现的解决方案。 3 天后,它按预期工作。只有 queue:work
运行s 的一个实例,它仅在停止 运行ning 时重新启动。时间表是每分钟 运行ning。
if ( ! strstr(shell_exec('ps xf'), 'php artisan queue:work'))
{
$schedule->command('queue:work')->everyMinute();
}
您也可以搜索 queue:work
而不是 php artisan queue:work
。 运行 shell_exec('ps xf')
修补一下,看看你得到了什么。