Randomize Command Execution Time with the Chaotic Schedule Package for Laravel

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

// Run a command every Tuesday, Saturday and Sunday on a random time between 04:20 and 06:09
    ->days([Schedule::TUESDAY, Schedule::SATURDAY, Schedule::SUNDAY])

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.

The post Randomize Command Execution Time with the Chaotic Schedule Package for Laravel appeared first on Laravel News.

Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.

Read more

© 2024 Extly, CB - All rights reserved.