Charrua
321
40
Laravel

Scheduler running with delay (not on time)

Posted 5 months ago by Charrua

Laravel 5.5 PHP 7.1

I have a strange issue on production server that delays the scheduler so tasks are not fired on time. It seems that for some reason the command artisan schedule:run sometimes takes time to load. If I run artisan schedule:run from console, it runs immediately, the issue is when is fired with the cron job. I have set the cron to fire by 5 minutes instead of all minutes to see more clear.

Cron log:

Sep 29 10:05:01 localhost CROND[17311]
Sep 29 10:10:01 localhost CROND[17846]
Sep 29 10:15:01 localhost CROND[18165]

Scheduler log:

Received ping at Saturday, 29-Sep-2018 10:06:11 EDT 
Received ping at Saturday, 29-Sep-2018 10:10:01 EDT 
Received ping at Saturday, 29-Sep-2018 10:18:55 EDT

The only task the scheduler has is a simple closure to measure time, no complex tasks.

$schedule->call(function () {
            return true;
        })
        ->everyMinute()
        ->pingBefore('...')

Somebody told me this could be a server load issue or clock sync, after running uptime; sar -q; etc the results are 10:52:05 up 4:29, 1 user, load average: 0,02, 0,04, 0,05 and clock is on sync.

The real issue is that if I have a task set to run eg at 10:05, it never runs, because the scheduler is loaded at 10:06.

Any ideas?

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.