Skip to content

Instantly share code, notes, and snippets.

@w1ndy
Created November 13, 2016 15:07
Show Gist options
  • Save w1ndy/6a6e99e07d7942d57c2dda57c3f9eefd to your computer and use it in GitHub Desktop.
Save w1ndy/6a6e99e07d7942d57c2dda57c3f9eefd to your computer and use it in GitHub Desktop.
Delaying for random seconds and executing a command
#!/bin/bash
# random_delay_and_do
# DELAY={{seconds}} ./rdd.sh {{COMMAND}} will force delay setting to {{seconds}}
hours=3
maxdelay=$(($hours*60*60))
rand=$(($RANDOM*1234%maxdelay))
delay=${DELAY:-$rand}
echo "sleeping $delay"
sleep $delay
"$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment