I have a project in Laravel 8 as the backend deployed on EC2 with ubuntu. I have scheduled few functions as cron jobs at specific time. But, the same cron job seems to run multiple times. So i put a test function as follows.
$schedule->call(function () {
Log::info('function testing');
})->dailyAt('8:00')->timezone('Asia/Qatar');
The above log prints around 39 times. After my research i added withoutOverlapping()
$schedule->call(function () {
Log::info('function testing');
})->dailyAt('8:00')
->timezone('Asia/Qatar')
->name('unique_event_name')
->withoutOverlapping();
The above one prints around 9 times.
I have a development server with the same code and similiar env. There it works fine. It is running only one time.
* * * * * cd backend_path && php artisan schedule:run >> /dev/null 2>&1
The above command i runs on crontab -e.
I’m unable to figure out the issue with my production server, Any help will be appreciated !!