Charrua
166
3
Laravel

Scheduler running some tasks twice

Posted 7 months ago by Charrua

I have some tasks on Kernel.php scheduler to run on different times, the problem is that some of them, not all, runs twice. I'm also using supervisor with 2 processes.

My Kernel.php:

<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        \App\Console\Commands\Automations\TwilioFillSMS::class,
        \App\Console\Commands\Appointments\AppCurrentDayComm::class,
        \App\Console\Commands\Appointments\AppDayBeforeComm::class,
        \App\Console\Commands\Appointments\AppIntroCurrentDayComm::class,
        \App\Console\Commands\Appointments\AppIntroDayBeforeComm::class,
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        
        //Fill SMS data
        $schedule->command('auto:fill-twilio-sms')->twiceDaily(5, 13)->emailOutputTo('...')->withoutOverlapping();



        //appointments notification group A (vip - new)
        $schedule->command('appt:intro-day-before')->dailyAt('11:35')->withoutOverlapping()->emailOutputTo('...');

        $schedule->command('appt:intro-current-day')
                        ->dailyAt('11:30')
                        ->skip(function () {
                            return date('N') == 6; //skip on saturday
                        })->withoutOverlapping()
                        ->emailOutputTo('...');

        //saturdays
        $schedule->command('appt:intro-current-day')
                        ->saturdays()
                        ->at('09:00')
                        ->withoutOverlapping()
                        ->emailOutputTo('...');

        



        //appointments notification group B (all others and goal appointments)
        $schedule->command('appt:day-before')->dailyAt('11:50')->withoutOverlapping()->emailOutputTo('...');

        $schedule->command('appt:current-day')
                        ->dailyAt('11:45')
                        ->skip(function () {
                            return date('N') == 6; //skip on saturday
                        })
                        ->withoutOverlapping()
                        ->emailOutputTo('...');

        $schedule->command('appt:current-day')
                        ->saturdays()
                        ->at('08:55')
                        ->withoutOverlapping()
                        ->emailOutputTo('...');
        

    }

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

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


}

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

Reply to

Use Markdown with GitHub-flavored code blocks.