簡體   English   中英

Laravel schedule:run 在添加到 cron 作業時不起作用

[英]Laravel schedule:run is not working when added into the cron job

我已經制定了一個命令並安排每 30 分鍾執行一次。 當我運行php artisan schedule:run它工作得很好並返回預期結果,但是當我在我的實時服務器上配置它時,我的 cron 作業確實運行但它沒有重新調整成功消息,而是返回了我的所有可用命令的列表laravel項目。 這就是我在做什么。

命令 Kernel:

$schedule->command('update:callLogs')
            ->everyMinute();

Cron 條目:

/usr/bin/php /home/ddsas9rm2f1g/public_html/clowdlink.com/crm/artisan schedule:run

這就是我得到的回應

Laravel 框架 5.8.38

Usage:
command [options] [arguments]

Options:
 -h, --help            Display this help message
 -q, --quiet           Do not output any message
 -V, --version         Display this application version
  --ansi            Force ANSI output
  --no-ansi         Disable ANSI output
 -n, --no-interaction  Do not ask any interactive question
  --env[=ENV]       The environment the command should run under
 -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
 (List of all availabe commands)

任何幫助都感激不盡。

編輯現在我的命令看起來像這樣

* * * * * cd /home/ddsas9rm2f1g/public_html/clowdlink.com/crm && php artisan update:callLogs

但是得到相同的響應,而當我復制相同的命令並使用膩子運行相同的命令並且它工作得很好。 現在已經一周了,我仍然停留在這個 cron 上。

我通過指定 PHP 的路徑而不是僅使用php來修復此問題。

從這個: cd /home/foobar && php artisan schedule:run

為此: cd /home/foobar && /usr/local/bin/php artisan schedule:run

這使我無法獲得可用工匠命令的列表,並給了我正確的 output。

我看得出您已經嘗試過了,但我認為其他人也會遇到這種情況。 我想您的問題與您使用的 PHP 版本有關,無法正確運行 PHP 腳本。 也許是 CLI 的 opcache 東西?

當我部署我的一個應用程序時,我也面臨着巨大的挑戰,並最終設法解決了這個問題:

cd /path-to-project && /opt/cpanel/ea-php71/root/opt/cpanel/ea-php74/root/usr/bin/php-cgi artisan schedule:run

我的應用程序使用 Laravel 5.7

你可以試試下面的代碼:

* * * * * php /home/ddsas9rm2f1g/public_html/clowdlink.com/crm/artisan schedule:run 1>> /dev/null 2>&1

>> /dev/null 2>&1 :我們將丟棄命令的所有 output。

您可以在 cron 中嘗試以下操作並共享 crontab.out 的 output

* * * * * cd /home/ddsas9rm2f1g/public_html/clowdlink.com/crm/ && php artisan schedule:run >> crontab.out 2>&1
*/30 * * * * php /home/ddsas9rm2f1g/public_html/clowdlink.com/crm/artisan schedule:run 1>> /dev/null 2>&1

要么

*/30 * * * * /usr/bin/php /home/ddsas9rm2f1g/public_html/clowdlink.com/crm/artisan schedule:run 1>> /dev/null 2>&1

要么

*/30 * * * * cd /home/ddsas9rm2f1g/public_html/clowdlink.com/crm && php artisan schedule:run >> /dev/null 2>&1

另請閱讀完整帖子: https://devnote.in/how-to-set-auto-database-backup-with-cron-scheduler-in-laravel/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM