Last active
February 16, 2017 09:30
-
-
Save ihipop/acacbd1740d5f5b32ba6 to your computer and use it in GitHub Desktop.
delay run Command at random but certain time period without sleep in crontab
This file contains 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 | |
#receive command | |
#you neet atd daemon to do this | |
cmd="$*" | |
echo $cmd | |
[[ $cmd == "" ]] && { echo 'Command Can Not be Empty' ; exit 1; } | |
command -v at >/dev/null 2>&1 || { echo "I require 'at command' but it's not installed. Aborting." >&2; exit 1; } | |
#set how many minutes to delay | |
range=2-350 | |
echo 'sleep ' $(shuf -i 1-60 -n 1) ';' $cmd |at now + $(shuf -i $range -n 1) min | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment