Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Calling this function causes the script to wait until the appropriate time
- # e.g. wait_until "01:00 GMT" will make it wait until 1AM GMT
- # Note that if the time is in the past it will just continue without waiting
- function wait_until {
- current_epoch=$(date +%s)
- target_epoch=$(date -d "$1" +%s)
- sleep_seconds=$(( $target_epoch - $current_epoch ))
- if [ "$sleep_seconds" -gt "0" ]
- then
- sleep $sleep_seconds
- fi
- }
Add Comment
Please, Sign In to add comment