Cron job not working properly when specified time
P粉347804896
P粉347804896 2024-03-28 15:24:27
0
2
517

I have a Laravel project v8 and I have created a cron job for database backup

It works every minute, but when I specify the time of day, it doesn't work.

The project time zone is "Asia/Kolkata" and my GoDaddy shared server time zone 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.

P粉347804896
P粉347804896

reply all(2)
P粉057869348

Replace your kernel.php

command('backup:clean')->everyMinute();
    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__.'/Commands');

        require base_path('routes/console.php');
    }
}

After this, set the cronjob on Cpanel and the time you want it to execute

Check the given time in cpanel, cron will definitely work

P粉232793765

You can run cron like this:

protected function schedule(Schedule $schedule)
{
     $schedule->command('backup:run')->dailyAt('03:51');
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template