-
-
Save mdpuma/45ec1c73b88333afa921 to your computer and use it in GitHub Desktop.
shell function sleep until
This file contains hidden or 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 | |
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