rndsleep – add a random delay to cron jobs

A command-line utility written in Go to sleep for a random period, then run another command line executable.

Typical usage would be to run puppet agent in onetime mode in cron to save resources – the random sleep will help to avoid thundering herd issues at the puppetmaster.

rndsleep --randmax=30 --command="puppet agent --no-daemonize --onetime"

would run puppet agent with a random timeout of 0-30s.

Can be compiled on all platforms that Go is available for. Download it from github.

One Comment

  1. Assuming you are using a modern shell you can also use this variation in cron:
    sleep $((RANDOM % 30 )); puppet agent --noop --onetime --no-daemonize
    The % value in the expansion is the ceiling.

Leave a Reply

Your email address will not be published. Required fields are marked *