【发布时间】:2021-09-25 00:38:10
【问题描述】:
在 laravel 中,我有一个 SnapShot 方法可以将数据复制到统计模型中。
当我跑步时
/var/www/laravel/artisan schedule:run
数据被添加到统计表中。
现在我在 /etc/crontab 中添加了以下行
* * * * * php /var/www/laravel/artisan schedule:run >> dev/null 2>&1
在我的 /var/log/syslog 我读到:
Jul 16 08:53:01 cluego CRON[24524]: (root) CMD (cd /usr/bin/php7.4 && php artisan schedule:run /dev/null 2>&1)
Jul 16 08:53:01 cluego CRON[24523]: (CRON) info (No MTA installed, discarding output)
Jul 16 08:54:01 cluego CRON[24599]: (root) CMD (php /var/www/laravel/artisan schedule:run /dev/null 2>&1)
Jul 16 08:54:01 cluego CRON[24598]: (CRON) info (No MTA installed, discarding output)
laravel.log 显示:
[2021-07-16 09:25:01] production.ERROR: No arguments expected for "schedule:run" command, got "/dev/null". {"exception":"[object] (Symfony\\Component\\Console\\Exception\\$
[stacktrace]
当我手动运行时,我得到以下结果:
root@xxxx:/var/www/laravel# php artisan schedule:run
Running scheduled command: '/usr/bin/php7.4' 'artisan' statistics:snap > '/dev/null' 2>&1
一个数据点被添加到统计表中,就像它应该做的那样。
谁能看到为什么 cronjob 没有像手动 schedule:run 一样运行 statistics:snap 命令?
【问题讨论】:
-
您是否重新加载了 cron 并重新启动它?