首页 > 解决方案 > laravel cron 没有触发,但其他 cron 正在触发

问题描述

我有一个 ubuntu 18.04 设置并运行 laravel 5.6,我已经在 crontab -e 中设置了默认调度程序

* * * * * php /var/www/html/laravel/artisan schedule:run >> /var/www/html/crons.txt 2>&1

这没有运行

我的内核代码

<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        'App\Console\Commands\CompletelyReviewInternship',
        'App\Console\Commands\MigrateUsers',
        'App\Console\Commands\MigrateUsersTwo',
        'App\Console\Commands\MigrateUsersThree',
        'App\Console\Commands\MigrateUsersFour',
        'App\Console\Commands\MigrateUsersFive',
        'App\Console\Commands\MigrateUsersSix',
        'App\Console\Commands\MigrateUsersSeven',
        'App\Console\Commands\MigrateUsersEight',
        'App\Console\Commands\MigrateUsersNine',
        'App\Console\Commands\MigrateUsersTen'
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        $schedule->command('review:internship')->hourly();

        $schedule->command('migrate:users')->dailyAt('17:40');

        $schedule->command('migrate:userstwo')->dailyAt('17:40');

        $schedule->command('migrate:usersthree')->dailyAt('17:40');

        $schedule->command('migrate:usersthree')->dailyAt('17:40');

        $schedule->command('migrate:usersfour')->dailyAt('17:40');

        $schedule->command('migrate:usersfive')->dailyAt('17:40');

        $schedule->command('migrate:userssix')->dailyAt('17:40');

        $schedule->command('migrate:usersseven')->dailyAt('17:40');

        $schedule->command('migrate:userseight')->dailyAt('17:40');

        $schedule->command('migrate:usersnine')->dailyAt('17:40');

        $schedule->command('migrate:usersten')->dailyAt('17:40');

    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__.'/Commands');

        require base_path('routes/console.php');
    }
}

请注意:-我的命令是用 php artisan 触发的,我使用 nginx 作为我的网络服务器

建议对此提出任何建议

标签: laravelubuntularavel-5laravel-5.6laravel-artisan

解决方案


我认为这可能有多种原因:

  • 您的应用程序处于维护模式。->evenInMaintenanceMode()在这种情况下,除非您使用每个命令,否则不会运行任何命令
  • 您正在使用时间,但您机器上的时间与您预期的不同,因此命令将在稍后运行。确保时间确实有效,或者尝试更改时间限制以->everyMinute()确保在这种情况下它不是问题

$commands另一方面,如果它们在Commands目录中,则不必在属性中列出所有命令。


推荐阅读