简体   繁体   English

无法在使用 Cpanel 托管时执行简单的 Laravel 的 cron 作业

[英]Cant execute a simple Laravel's cron job in hosting with Cpanel

First of all, sorry for my english, im not a native talker.首先,对不起我的英语,我不是母语人士。 I'm learning Laravel, and I got stuck in a little problem.我正在学习 Laravel,遇到了一个小问题。 I cant execute a very simple cron job in a Hosting with Cpanel.我无法在 Hosting with Cpanel 中执行非常简单的 cron 作业。 I have this code in Kernel.php:我在 Kernel.php 中有这个代码:

protected function schedule(Schedule $schedule)
{
    $schedule->call(function () {       
        \Log::info('This is a log');
    })->everyMinute();
}   

I had enabled the Cron job in Cpanel, every one minute (* * * * *), and evidently something is executing, because every minute i have this error registered in the log (obviusly not my text):我在 Cpanel 中启用了 Cron 作业,每隔一分钟 (* * * * *),显然有一些事情正在执行,因为每一分钟我都会在日志中记录这个错误(显然不是我的文本):

[2020-04-19 18:47:26] local.ERROR: Declaration of Carbon\Translator::setLocale($locale) must be compatible 
with Symfony\Contracts\Translation\LocaleAwareInterface::setLocale(string $locale) 
{"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): 
Declaration of Carbon\\Translator::setLocale($locale) must be compatible with 
Symfony\\Contracts\\Translation\\LocaleAwareInterface::setLocale(string $locale) 
at /home/grupodem/bad-conf/vendor/nesbot/carbon/src/Carbon/Translator.php:18)
[stacktrace]
#0 {main}
"}  

The goal of this simple exercise that I wanted to do, was just try Cron Jobs in Cpanel.我想做的这个简单练习的目标就是在 Cpanel 中尝试 Cron Jobs。 In fact, the code it's very simple, but it doesn't work anyway.实际上,代码很简单,但无论如何都不起作用。 The PHP version of the server is 7.3.16 and the project is Laravel 7.服务器的PHP版本为7.3.16,工程为Laravel 7。

Thank you very much in advance!非常感谢您! Best regards!此致! Lucas卢卡斯

It's not an issue with the cronjob.这不是 cronjob 的问题。 It's an issue with laravel.这是 laravel 的问题。

Method 1: Add "symfony/translation": "4.3.8" in your composer.json & run composer update方法 1:在 composer.json 中添加 "symfony/translation": "4.3.8" 并运行 composer update

Method 2: Run composer require symfony/translation:4.3 Then run composer update方法二:运行 composer require symfony/translation:4.3 然后运行 composer update

This should fix the issue you are facing这应该可以解决您面临的问题

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

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