Stanleyy
Stanleyy

Reputation: 328

Scheduler in Laravel Forge not working correctly

As per the Forge documentation regarding task scheduling with Laravel scheduler, I have set up a schedule on forge with the command

php8.1 /home/forge/default/artisan schedule:run

User is forge and frequency is set to every minute

My keneral.php has a schedule that is supposed to go off only right before midnight at whichever timezone it is for the user. However, when the scheduler runs on forge it seems like the command is getting executed every minute instead of checking what the schedule function has to say about it.

protected function schedule(Schedule $schedule)
    {
        $users = User::all();


        foreach ($users as $user) {
            $timezone = $user->timezone;


            $schedule->command('nullDay:daily')->timezone($timezone)->between('23:50', '23:58');
        }
    }

This schedule function works great in local when running schedule:work so I tried use that instead of schedule:run in the forge command input but it doesn't seem to work.

This is the output when I have the php8.1 /home/forge/default/artisan schedule:run with the kernal code above:

[2022-01-06T20:07:02+00:00] Running scheduled command: '/usr/bin/php8.1' 'artisan' nullDay:daily > '/dev/null' 2>&1

Upvotes: 3

Views: 1284

Answers (1)

Related Questions