Created
April 30, 2013 07:34
-
-
Save mrc/5487168 to your computer and use it in GitHub Desktop.
Poor uptime for zsh and Windows
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
zmodload zsh/datetime | |
function uptime() { | |
reboot_time=$(net statistics server | awk '/Statistics since/{print $3, $4, $5}') | |
strftime -r -s reboot_secs '%d/%m/%Y %H:%M:%S %p' "$reboot_time" | |
(( uptime = $EPOCHSECONDS - $reboot_secs )) | |
(( up_days = uptime / 86400 )) | |
(( up_hours = (uptime % 86400) / 3600 )) | |
(( up_minutes = ((uptime % 86400) % 3600 ) / 60)) | |
(( up_seconds = ((uptime % 86400) % 3600 ) % 60)) | |
strftime -s now_time '%H:%M:%S' $EPOCHSECONDS | |
printf " $now_time up %d days, %2d:%02d\n" $up_days $up_hours $up_minutes | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment