Home > OS >  I am trying to run a task schedule on cPanel but not working
I am trying to run a task schedule on cPanel but not working

Time:10-28

I am trying to run cron job on the daily bases at 16:00 but unfortunately not working please help me thanks

Note :- when i select schedule ->everMinute() it works perfectly.

/home3/urbanhq6/public_html/new/app/Console/Kernel.php

 /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        $schedule->command('reminder:email')
             ->dailyAt('16:00');
    }

cron job timing set

Minute  Hour    Day  Month  Weekday 
0   16  *        *    *              

CodePudding user response:

First, you should adjust your cPanel cron to run every minute, with timings of * * * * *. Laravel handles its own scheduling via rules (like ->dailyAt('16:00')) in the Kernel.php file; running every minute lets Laravel do that without needing adjustments when you add a new command to the schedule.

Now, running at 0 16 * * * should still work for this particular set of rules. The likely answer is your server and your Laravel are on different timezones - check the timezone on the server with date, and check config/app.php's timezone value.

If there's a mismatch, your cron is running at 16:00 server time, but Laravel is adjusting the time to its own timezone, which means the two don't match. Switching your cron to * * * * * will fix this - the cron will start running (as it does with everyMinute()) - but the task will run at an unexpected hour.

  • Related