Ubuntu 本地系统中带有crontab的Laravel 5中的调度器不工作

Ubuntu 本地系统中带有crontab的Laravel 5中的调度器不工作,ubuntu,cron,laravel-5,crontab,scheduler,Ubuntu,Cron,Laravel 5,Crontab,Scheduler,当我在终端中运行“php artisan schedule:run”时,它执行的是exptected,但当我配置crontab自动执行它时,它没有任何效果。 我在Kernel.php中的代码是: $schedule->call(function () { $example=Example::orderBy('updated_at', 'asc')->limit(1)->first(); $example->touch();

当我在终端中运行“php artisan schedule:run”时,它执行的是exptected,但当我配置crontab自动执行它时,它没有任何效果。 我在Kernel.php中的代码是:

$schedule->call(function () {
            $example=Example::orderBy('updated_at', 'asc')->limit(1)->first();
            $example->touch();
        })->everyMinute();
我在crontab-e中

* * * * * php /path/to/laravel/project schedule:run 1>> /dev/null 2>&1
我尝试执行crontab文件中的其他命令,其他命令都正常工作。所以我想这可能是php的问题,但我没有任何输出来知道问题出在哪里


你知道怎么解决这个问题吗?

我想你的路还不完整。您必须在路径中包含Artisan

* * * * * php /path/to/artisan schedule:run >> /dev/null 2>&1
例如:

* * * * * php /var/www/html/laravel_project/artisan schedule:run >> /dev/null 2>&1
有关更多信息,请参阅Laravel文档:

编辑

如果要查看Cronjob的输出,则必须删除以下内容:

>> /dev/null 2>&1

有时问题是Cron不知道PHP在哪里。在这种情况下,必须定义本地php安装的路径。在我的机器里

crontab -e
有条目吗

* * * * * /usr/local/bin/php /home/younus/TruckJee/Code/Panel/artisan schedule:run
它完全按照计划进行。此外,要检查crobjobs是否正在运行,请使用

cat /var/log/syslog
它应该显示您的cronjob是否正在实际运行。(即)


谢谢你说的对,我刚刚添加了artisan,现在正在努力让它工作:****php/path/to/laravel/project/artisan schedule:run 1>>/dev/null 2>&1
May 23 16:21:01 farveaz cron[1105]: (root) RELOAD (crontabs/root)
May 23 16:21:01 farveaz CRON[6812]: (younus) CMD (/usr/local/bin/php /home/younus/TruckJee/Code/Panel/artisan schedule:run)
May 23 16:21:01 farveaz CRON[6811]: (CRON) info (No MTA installed, discarding output)