Skip to content

Instantly share code, notes, and snippets.

@mdpuma
Forked from p0c/sleep_until.sh
Last active February 2, 2016 18:53
Show Gist options
  • Save mdpuma/45ec1c73b88333afa921 to your computer and use it in GitHub Desktop.
Save mdpuma/45ec1c73b88333afa921 to your computer and use it in GitHub Desktop.
shell function sleep until
#!/bin/bash
current_time=$(date +%s)
target_time=$(date -d "$*" +%s)
seconds=$(( $target_time - $current_time ))
echo "sleeping $seconds (`date -d "$*"`)"
sleep $seconds
# Usage:
# sleep_until tomorrow 11:50
# sleep_until 24 hours
# sleep_until 2015-02-19 11:50
# sleep_until next day 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment