Guest User

Untitled

a guest
Jul 22nd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. # Calling this function causes the script to wait until the appropriate time
  2. # e.g. wait_until "01:00 GMT" will make it wait until 1AM GMT
  3. # Note that if the time is in the past it will just continue without waiting
  4. function wait_until {
  5. current_epoch=$(date +%s)
  6. target_epoch=$(date -d "$1" +%s)
  7. sleep_seconds=$(( $target_epoch - $current_epoch ))
  8. if [ "$sleep_seconds" -gt "0" ]
  9. then
  10. sleep $sleep_seconds
  11. fi
  12. }
Add Comment
Please, Sign In to add comment