简体   繁体   中英

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. I cant execute a very simple cron job in a Hosting with Cpanel. I have this code in 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):

[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. 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.

Thank you very much in advance! Best regards! Lucas

It's not an issue with the cronjob. It's an issue with laravel.

Method 1: Add "symfony/translation": "4.3.8" in your composer.json & run composer update

Method 2: Run composer require symfony/translation:4.3 Then run composer update

This should fix the issue you are facing

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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