Created
November 13, 2016 15:07
-
-
Save w1ndy/6a6e99e07d7942d57c2dda57c3f9eefd to your computer and use it in GitHub Desktop.
Delaying for random seconds and executing a command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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