Created
July 3, 2012 19:23
-
-
Save ganglio/3042169 to your computer and use it in GitHub Desktop.
BASH: Revised Uptime Geeklet
This file contains 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 | |
then=$(sysctl kern.boottime | awk '{print $5}' | sed "s/,//") | |
now=$(date +%s) | |
diff=$(($now-$then)) | |
days=$(($diff/86400)); | |
diff=$(($diff-($days*86400))) | |
hours=$(($diff/3600)) | |
diff=$(($diff-($hours*3600))) | |
minutes=$(($diff/60)) | |
seconds=$(($diff-($minutes*60))) | |
printf "Uptime: %dd%02dh%02dm%02ds" $days $hours $minutes $seconds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment