Laravel 调度程序不 运行 命令,但可以 运行 手动
Laravel Scheduler don't run commands, but they can be run manually
我有 3 个命令 运行 在计划中。
$schedule->command("update:branchsales")->everyFiveMinutes()->timezone('America/Sao_Paulo')->withoutOverlapping();
$schedule->command("update:billing")->everyFiveMinutes()->timezone('America/Sao_Paulo')->withoutOverlapping();
$schedule->command("update:sales")->everyFiveMinutes()->timezone('America/Sao_Paulo')->withoutOverlapping();
但在日志中,我们可以看到其中只有 2 个实际上是 运行ning。
No scheduled commands are ready to run.
Running scheduled command: '/usr/local/bin/php' 'artisan' update:sales > '/dev/null' 2>&1
No scheduled commands are ready to run.
No scheduled commands are ready to run.
Running scheduled command: '/usr/local/bin/php' 'artisan' update:branchsales > '/dev/null' 2>&1
No scheduled commands are ready to run.
No scheduled commands are ready to run.
Running scheduled command: '/usr/local/bin/php' 'artisan' update:sales > '/dev/null' 2>&1
No scheduled commands are ready to run.
No scheduled commands are ready to run.
Running scheduled command: '/usr/local/bin/php' 'artisan' update:branchsales > '/dev/null' 2>&1
No scheduled commands are ready to run.
我可以 运行 手动 update:billing
但它突然停止到计划中的 运行。
到昨天他们都运行宁。
我们将不胜感激。
编辑:
update:sales
现在也停了
No scheduled commands are ready to run.
Running scheduled command: '/usr/local/bin/php' 'artisan' update:sales > '/dev/null' 2>&1
No scheduled commands are ready to run.
No scheduled commands are ready to run.
Running scheduled command: '/usr/local/bin/php' 'artisan' update:branchsales > '/dev/null' 2>&1
No scheduled commands are ready to run.
No scheduled commands are ready to run.
Running scheduled command: '/usr/local/bin/php' 'artisan' update:sales > '/dev/null' 2>&1
No scheduled commands are ready to run.
No scheduled commands are ready to run.
Running scheduled command: '/usr/local/bin/php' 'artisan' update:branchsales > '/dev/null' 2>&1
No scheduled commands are ready to run.
No scheduled commands are ready to run.
No scheduled commands are ready to run.
No scheduled commands are ready to run.
Running scheduled command: '/usr/local/bin/php' 'artisan' update:branchsales > '/dev/null' 2>&1
No scheduled commands are ready to run.
No scheduled commands are ready to run.
No scheduled commands are ready to run.
No scheduled commands are ready to run.
Running scheduled command: '/usr/local/bin/php' 'artisan' update:branchsales > '/dev/null' 2>&1
检查 运行ning 进程,也许命令正在工作(卡住)并且不 运行 因为 withoutOverlapping
.
ps aux | grep 'php artisan'
几天前,我在研究了以下解决方案后遇到了几乎相同的问题,
protected function osProcessIsRunning($needle)
{
// get process status. the "-ww"-option is important to get the full output!
exec('ps aux -ww', $process_status);
// search $needle in process status
$result = array_filter($process_status, function($var) use ($needle) {
return strpos($var, $needle);
});
// if the result is not empty, the needle exists in running processes
if (!empty($result)) {
return true;
}
return false;
}
protected function schedule(Schedule $schedule)
{
if (!$this->osProcessIsRunning('update:sales')) {
$schedule->command("update:branchsales")->everyFiveMinutes()->timezone('America/Sao_Paulo')->withoutOverlapping();
}
//Similarly do for other two commands
}
现在只有 运行 你在 cron 作业中的调度命令像 schedule:运行 它也会防止服务器上的额外负载,我发现了这个在 Laracast 上回答忘记 link 否则我会分享!
我找到了那个问题的答案 。希望对大家有帮助。
刚刚在项目文件夹上执行了 php artisan cache:clear
,现在似乎一切正常。
我有 3 个命令 运行 在计划中。
$schedule->command("update:branchsales")->everyFiveMinutes()->timezone('America/Sao_Paulo')->withoutOverlapping();
$schedule->command("update:billing")->everyFiveMinutes()->timezone('America/Sao_Paulo')->withoutOverlapping();
$schedule->command("update:sales")->everyFiveMinutes()->timezone('America/Sao_Paulo')->withoutOverlapping();
但在日志中,我们可以看到其中只有 2 个实际上是 运行ning。
No scheduled commands are ready to run.
Running scheduled command: '/usr/local/bin/php' 'artisan' update:sales > '/dev/null' 2>&1
No scheduled commands are ready to run.
No scheduled commands are ready to run.
Running scheduled command: '/usr/local/bin/php' 'artisan' update:branchsales > '/dev/null' 2>&1
No scheduled commands are ready to run.
No scheduled commands are ready to run.
Running scheduled command: '/usr/local/bin/php' 'artisan' update:sales > '/dev/null' 2>&1
No scheduled commands are ready to run.
No scheduled commands are ready to run.
Running scheduled command: '/usr/local/bin/php' 'artisan' update:branchsales > '/dev/null' 2>&1
No scheduled commands are ready to run.
我可以 运行 手动 update:billing
但它突然停止到计划中的 运行。
到昨天他们都运行宁。
我们将不胜感激。
编辑:
update:sales
现在也停了
No scheduled commands are ready to run.
Running scheduled command: '/usr/local/bin/php' 'artisan' update:sales > '/dev/null' 2>&1
No scheduled commands are ready to run.
No scheduled commands are ready to run.
Running scheduled command: '/usr/local/bin/php' 'artisan' update:branchsales > '/dev/null' 2>&1
No scheduled commands are ready to run.
No scheduled commands are ready to run.
Running scheduled command: '/usr/local/bin/php' 'artisan' update:sales > '/dev/null' 2>&1
No scheduled commands are ready to run.
No scheduled commands are ready to run.
Running scheduled command: '/usr/local/bin/php' 'artisan' update:branchsales > '/dev/null' 2>&1
No scheduled commands are ready to run.
No scheduled commands are ready to run.
No scheduled commands are ready to run.
No scheduled commands are ready to run.
Running scheduled command: '/usr/local/bin/php' 'artisan' update:branchsales > '/dev/null' 2>&1
No scheduled commands are ready to run.
No scheduled commands are ready to run.
No scheduled commands are ready to run.
No scheduled commands are ready to run.
Running scheduled command: '/usr/local/bin/php' 'artisan' update:branchsales > '/dev/null' 2>&1
检查 运行ning 进程,也许命令正在工作(卡住)并且不 运行 因为 withoutOverlapping
.
ps aux | grep 'php artisan'
几天前,我在研究了以下解决方案后遇到了几乎相同的问题,
protected function osProcessIsRunning($needle)
{
// get process status. the "-ww"-option is important to get the full output!
exec('ps aux -ww', $process_status);
// search $needle in process status
$result = array_filter($process_status, function($var) use ($needle) {
return strpos($var, $needle);
});
// if the result is not empty, the needle exists in running processes
if (!empty($result)) {
return true;
}
return false;
}
protected function schedule(Schedule $schedule)
{
if (!$this->osProcessIsRunning('update:sales')) {
$schedule->command("update:branchsales")->everyFiveMinutes()->timezone('America/Sao_Paulo')->withoutOverlapping();
}
//Similarly do for other two commands
}
现在只有 运行 你在 cron 作业中的调度命令像 schedule:运行 它也会防止服务器上的额外负载,我发现了这个在 Laracast 上回答忘记 link 否则我会分享!
我找到了那个问题的答案
刚刚在项目文件夹上执行了 php artisan cache:clear
,现在似乎一切正常。