简体   繁体   English

Laravel 8 通过 AWS EC2 上的 cron 计划 linux - 命令未运行

[英]Laravel 8 schedule via cron on AWS EC2 linux - commands not running

I've created a cron job in AWS EC2 but it is not working at scheduled time.when i run command in cli php artisan schedule:run it is working fine but not execute automatically at scheduled time.我在 AWS EC2 中创建了一个 cron 作业,但它没有在预定时间运行。当我在 cli php artisan schedule:run 中运行命令时,它工作正常但没有在预定时间自动执行。

php version=7.4.3 php 版本=7.4.3

php Framework = 8 php 框架 = 8

I added cron entry in crontab using crontab -e我使用 crontab -e 在 crontab 中添加了 cron 条目

* * * * * cd /var/www/html/artisan schedule:run >> /dev/null 2>&1

在此处输入图像描述

/var/www/html/app/Console\Kernal /var/www/html/app/Console\Kernal

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

    }

       /**
         * The Artisan commands provided by your application.
         *
         * @var array
         */
        protected $commands=[
            '\App\Console\Commands\BookingCron',
        ];

There's an unwanted cd in your cron command, it should be你的 cron 命令中有一个不需要的cd ,它应该是

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

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

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