prueba este
sys.scheduled_run /path/to/my/script 5
función principal
function sys.scheduled_run(){
local PATH_TO_ACTION MINS SLEEPTIME
PATH_TO_ACTION=$1
MINS=$2
SLEEPTIME=$(($MINS * 60))
echo "Sleeping for $MINS minute ($SLEEPTIME seconds) and then running $PATH_TO_ACTION"
ui.countdown $SLEEPTIME
$PATH_TO_ACTION
echo "Done"
if [ "REPEAT" == "$3" ]
then
echo "Going for Repeat"
sys.scheduled_run "[email protected]"
fi
}
función de cuenta atrás
function ui.countdown(){ #USAGE ui.countdown 60 countdown for 60 seconds
local SECONDS=$1
local START=$(date +%s)
local END=$((START + SECONDS))
local CUR=$START
while [[ $CUR -lt $END ]]
do
CUR=$(date +%s)
LEFT=$((END-CUR))
printf "\r%02d:%02d:%02d" \
$((LEFT/3600)) $(((LEFT/60)%60)) $((LEFT%60))
sleep 1
done
echo " "
}
Y sería el cuidado downvoter de explicar? –