Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Laravel 5 laravel 5.7应用程序中的计划任务在错误时间触发_Laravel 5_Cron - Fatal编程技术网

Laravel 5 laravel 5.7应用程序中的计划任务在错误时间触发

Laravel 5 laravel 5.7应用程序中的计划任务在错误时间触发,laravel-5,cron,Laravel 5,Cron,在Laravel5.7应用程序中,我遇到了一个问题,即发送电子邮件的预定任务在错误的时间收到。 在我的ubuntu 16中,在crontab的Digital Ocean Server下,使用以下命令: crontab-e 我加了一行: * * * * * cd /var/www/html/the-box-booking && php artisan schedule:run >> /dev/null 2>&1 date_default_timezone

在Laravel5.7应用程序中,我遇到了一个问题,即发送电子邮件的预定任务在错误的时间收到。 在我的ubuntu 16中,在crontab的Digital Ocean Server下,使用以下命令: crontab-e

我加了一行:

* * * * * cd /var/www/html/the-box-booking && php artisan schedule:run >> /dev/null 2>&1
date_default_timezone_set('Asia/Dubai');
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');
}
浏览器中的php显示下一步:

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
我认为console命令使用cli配置。 我签入命令行:

 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
我打开/etc/php/7.1/cli/php.ini,看到:

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Asia/Dubai
Timezone = Asia/Dubai
在bootstrap/app.php中,我添加了一行:

* * * * * cd /var/www/html/the-box-booking && php artisan schedule:run >> /dev/null 2>&1
date_default_timezone_set('Asia/Dubai');
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');
}
在app/Console/Kernel.php中,我添加了一行:

* * * * * cd /var/www/html/the-box-booking && php artisan schedule:run >> /dev/null 2>&1
date_default_timezone_set('Asia/Dubai');
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');
}
因此,我在日志中看到了很多信息行,但发送报告的时间不同。今天晚上21点我收到了

我重新启动了cron、apache和OS

错误在哪里以及如何修复

谢谢

您可以更改app/config.php的“时区”

这将为项目设置默认时区

对于发送邮件而不是设置cron,您应该设置队列功能

参考链接: