Created
February 11, 2014 18:11
-
-
Save PHLAK/8940598 to your computer and use it in GitHub Desktop.
24 hour while loop in bash
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 | |
## Script start time | |
START=$(date +%s) | |
## Total run time | |
DURRATION=$((60 * 60 * 24)) | |
## Total running time | |
UPTIME=$(($(date +%s) - $START)) | |
while [[ $UPTIME < $DURRATION ]]; do | |
## Logic here... | |
echo -n "Time remaining: " | |
echo $(($DURRATION - $UPTIME)) | |
## Sleep for a bit | |
sleep 2 | |
## Update running time | |
UPTIME=$(($(date +%s) - $START)) | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment