Search code examples
laravelscheduled-tasksschedulecron-taskcrontrigger

Laravel scheduled tasks created by users


I have a very big database that consisted of original posts.

I send these posts to my users. So here is where I lost. I want my users to create scheduled tasks by selecting time intervals like "every 15 mins, every 30 mins." via the form.

The system will send x amount of posts to the users according to the periods their choose.

I have 4-5K users. So it'll be around 4-5k scheduled tasks. How may i do that? I'll be more than glad if anyone can help me. Thanks in advance.


Solution

  • You have to write the scheduled commands for the times that users want to select and put the commands in the scheduler and execute the commands are the same times

    ex:

      protected function schedule(Schedule $schedule)
    {
        $schedule->command(CommandEveryMinute::class)->everyMinute();
        $schedule->command(CommandEveryTwoMinutes::class)->everyTwoMinutes();
    }