Laravel Packages

Randomize Command Execution Time with the Chaotic Schedule Package for Laravel

Published
Randomize Command Execution Time with the Chaotic Schedule Package for Laravel image

The chaotic-schedule package for Laravel allows you to randomize scheduled command execution time and date intervals via Pseudorandom number generators (PRNGs):

Ever wanted to run your scheduled commands on random times of the day, or on certain days of the week? Or you may need to send some notifications not on fixed date times, but rather on random intervals hence it feels more human. Then this is the package you're looking for.

This Laravel packages enables you to run commands on random intervals and periods while respecting the boundaries set exclusively by you.

One use-case mentioned in the readme is sending user notifications or emails but sending them randomly to add a more personal human touch. Avoiding the sending of these messages at regular intervals at the same time would be more recognizably automated:

// Run a command daily on a random time between 08:15 and 11:42
$schedule->command('inspire')->daily()->atRandom('08:15','11:42');
 
// Run a command every Tuesday, Saturday and Sunday on a random time between 04:20 and 06:09
$schedule->command('your-command-signature:here')
->days([Schedule::TUESDAY, Schedule::SATURDAY, Schedule::SUNDAY])
->atRandom('04:20','06:09');

This package includes quite a few methods to define your random specifications based on several factors, such as:

  • dailyAtRandom()
  • hourlyAtRandom()
  • hourlyMultipleAtRandom()
  • randomDays()
  • And more...

You can learn more about this package, get full installation instructions, and view the source code on GitHub.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Sponsored

masteringlaravel logo
Laravel Code Review

Get expert guidance in a few days with a Laravel code review

Visit Laravel Code Review

The latest

View all →
CPX: The Composer Package Executor for PHP image

CPX: The Composer Package Executor for PHP

Read article
Laravel AI SDK Adds Human-in-the-Loop Tool Approval image

Laravel AI SDK Adds Human-in-the-Loop Tool Approval

Read article
Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals image

Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals

Read article
Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs image

Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs

Read article
Blade Formatting in Laravel Pint image

Blade Formatting in Laravel Pint

Read article
Inertia DevTools Is Now on the Chrome Web Store image

Inertia DevTools Is Now on the Chrome Web Store

Read article