mardi 4 juin 2019

scheduled tasks In laravel 5.7 app triggered at wrong time

In laravel 5.7 app I have a problem that scheduled tasks with email sending are recieved at wrong time. in my ubuntu 16 under Digital Ocean Server in crontab with command : crontab -e

I added line :

* * * * * cd /var/www/html/the-box-booking && php artisan schedule:run >> /dev/null 2>&1

php in browser shows next :

PHP Version 7.1.17-1+ubuntu16.04.1+deb.sury.org+1
...
date
date/time support   enabled
timelib version 2016.05
"Olson" Timezone Database Version   0.system
Timezone Database   internal
Default timezone    Asia/Dubai
Directive   Local Value Master Value

date.default_latitude        31.7667     31.7667
date.default_longitude       35.2333     35.2333
date.sunrise_zenith          90.583333   90.583333
date.sunset_zenith           90.583333   90.583333
date.timezone                Asia/Dubai  Asia/Dubai

I suppose that console command use cli configurations. I check in command line :

 php -v
PHP 7.1.17-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: May  5 2018 04:55:21) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.1.17-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

I open /etc/php/7.1/cli/php.ini and see:

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Asia/Dubai
Timezone = Asia/Dubai

In bootstrap/app.php I added line :

date_default_timezone_set('Asia/Dubai');

In app/Console/Kernel.php I added line :

protected function schedule(Schedule $schedule)
{
    \Log::info( 'report:available-spaces-by-zones Report run # ' . time()  );
    $schedule->command('report:available-spaces-by-zones')->daily('18:00');
}

as a result I see a lot of info lines in my logs, but time of report sent if different. Today I recieved it at 21 pm.

I restarted cron, apache and OS.

Where error and how to fix it?

Thanks!



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/2WoV4uv
via IFTTT

Aucun commentaire:

Enregistrer un commentaire