Php Laravel计划未运行

Php Laravel计划未运行,php,laravel,cron,Php,Laravel,Cron,我和拉威尔的日程安排有问题。它的设置正确,命令是正确的,因为我可以从终端运行它,但它根本不工作。据我所知,CRON作业是正确的,因为它显示为sudo服务CRON status 但是php artisan schedule:run说没有任何东西排队。我的Kernel.php如下 class Kernel extends ConsoleKernel { /** * The Artisan commands provided by your application. *

我和拉威尔的日程安排有问题。它的设置正确,命令是正确的,因为我可以从终端运行它,但它根本不工作。据我所知,CRON作业是正确的,因为它显示为
sudo服务CRON status

但是
php artisan schedule:run
说没有任何东西排队。我的Kernel.php如下

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
      'App\Console\Commands\ResetBars',
      'App\Console\Commands\ResetUsers',
      'App\Console\Commands\UpdateBars',
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        $schedule->command('reset:bars')->hourlyAt(1);
        $schedule->command('reset:users')->daily();
        //$schedule->command('update:bars')->dailyAt('8:00');
    }

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

        require base_path('routes/console.php');
    }
}
我在命令的末尾有一个松弛日志(我已经验证了它是有效的),它在hourlyAt(1)时没有发送任何内容,所以它应该在8:01运行,但它没有

有人对它为什么不运行有什么想法吗?它是否正在排队,只是没有运行

这在cron选项卡中

# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
* * * * * php ~/var/www/BarhopAPI/artisan schedule:run >> /dev/null 2>&1
谢谢

  • 扎克

好的,我按照这些步骤来确保我做对了

crontab-l
来自@devk,非常感谢

要将crontab作业添加到您的Laravel安装程序中,它是
crontab-e
,当提示输入什么类型(如果您是第一次设置它)时,点击
2
转到nano,然后在星号后粘贴以下内容

***php/var/www/Laravel/artisan schedule:run>/dev/null 2>&1

显然,将
/var/www/Laravel
替换为Laravel安装的路径

编辑:那不行。
Edit2:@devk帮助我修复了它,需要删除
~

我在设置CRON作业时遇到了同样的问题

我使用了“dailyAt()”来运行CRON,实际上,我的CRON是 正在运行,但时区不是我自己的。请去检查一下你的行李 “config/app.php”检查您的时区(我刚刚更改了时区) 至“亚洲/加尔各答”)

要测试CRON,请在schedule()方法中对调度程序进行注释,并添加新的调度(此步骤将帮助您检查CRON是否正常工作


请确保您的CRON正在工作

您可以发布conjob命令吗?我如何获得该命令?我现在把CRON选项卡中的内容放在问题中
crontab-l
-只需在itOkay中复制项目目录中的行,我想我当时发现了问题。我刚刚运行了这个命令
***php~/var/www/MyFolder/artisan schedule:run>>/dev/null 2>&1
,但后来运行了crontab-l,它说,“根目录没有crontab”哦。我没有把它添加到crontab中。啊,愚蠢的问题和愚蠢的答案。让我谷歌如何添加它。
$schedule->command('jobexp:warning')->cron('* * * * *');

php artisan schedule:run