指定时间时,Cron Job不起作用
我有一个Laravel Project V8,并且我创建了一个CRON的工作DB备份工作,
它每分钟都可以正常工作,但是当我指定每天的时间时,它无法正常工作。
Project TimeZone是“亚洲/加尔各答”,而我的Godaddy共享服务器时区为UTC。
kernel.php
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('backup:clean')->everyMinute();
$schedule->command('backup:run')->cron('51 3 * * *');
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}
我在cpanel上的cronjob。
I have a Laravel project v8 and I have created a cron job for DB backup
It's working every minute but it is not working when I specify the time for daily.
Project timezone is 'Asia/Kolkata' and my GoDaddy shared server timezone is UTC.
kernel.php
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('backup:clean')->everyMinute();
$schedule->command('backup:run')->cron('51 3 * * *');
}
/**
* Register the commands for the application.
*
* @return void
*/
protected function commands()
{
$this->load(__DIR__.'/Commands');
require base_path('routes/console.php');
}
}
my cronjob on Cpanel.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以这样运行Cron:
You can run cron like this:
替换您的 kernel.php
,然后在CPANEL上设置Cronjob之后,您想执行的时间
检查Cpanel中的给定时间是否肯定会起作用
Replace your kernel.php
And after this set cronjob on Cpanel with the time on which you want to execute
Check that the given time in cpanel the cron will work definitely