Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scheduled tasks dont run if the previous instance of the task is still running #53640

Open
abbasudo opened this issue Nov 23, 2024 · 1 comment

Comments

@abbasudo
Copy link

Laravel Version

11.30

PHP Version

8.3.2

Database Driver & Version

SQLite

Description

Hello,

Thanks for your awesome work at Laravel.

I came across an unexpected behavior when using the schedule feature, as stated at this link "By default, scheduled tasks will be run even if the previous instance of the task is still running.". However, this is not working as expected in the scope of seconds.
Notice how the 3rd operation started at 18:30:30 and took 5 seconds to finish and the 4th operation didnt start until the 3rd one finished at 18:30:35.

php artisan schedule:work

  2024-11-23 18:30:28 Running ["artisan"  broadcast:send 1] ................................................................................ 1s DONE
  ⇂ "C:\php\php-8.3.2-Win32-vs16-x64\php.exe" "artisan" broadcast:send 1 > "NUL" 2>&1
  2024-11-23 18:30:29 Running ["artisan"  broadcast:send 1] ................................................................................ 1s DONE
  ⇂ "C:\php\php-8.3.2-Win32-vs16-x64\php.exe" "artisan" broadcast:send 1 > "NUL" 2>&1
  2024-11-23 18:30:30 Running ["artisan"  broadcast:send 1] ................................................................................ 5s DONE
  ⇂ "C:\php\php-8.3.2-Win32-vs16-x64\php.exe" "artisan" broadcast:send 1 > "NUL" 2>&1
  2024-11-23 18:30:36 Running ["artisan"  broadcast:send 1] ................................................................................ 1s DONE
  ⇂ "C:\php\php-8.3.2-Win32-vs16-x64\php.exe" "artisan" broadcast:send 1 > "NUL" 2>&1
  2024-11-23 18:30:38 Running ["artisan"  broadcast:send 1] ................................................................................ 1s DONE

Steps To Reproduce

create normal new laravel app

laravel new test
cd test
php artisan make:command broadcastCommand

broadcastCommand.php:

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class BroadcastCommand extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'broadcast:send {brokerId}';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Send broadcast messages to channel.';

    /**
     * Execute the console command.
     */
    public function handle()
    {
        sleep(random_int(1, 5));
    }
}

console.php :

Schedule::command(' broadcast:send 1')->everySecond();

run the schedule:

php artisan schedule:work
@Mdhesari
Copy link

This issue already exists! #53342

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants