Guest User

Untitled

a guest
Nov 20th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. #!/bin/bash
  2. then=$(sysctl kern.boottime | awk '{print $5}' | sed "s/,//")
  3. now=$(date +%s)
  4. diff=$(($now-$then))
  5.  
  6. days=$(($diff/86400));
  7. diff=$(($diff-($days*86400)))
  8. hours=$(($diff/3600))
  9. diff=$(($diff-($hours*3600)))
  10. minutes=$(($diff/60))
  11. seconds=$(($diff-($minutes*60)))
  12.  
  13. printf "Uptime: %dd%02dh%02dm%02ds" $days $hours $minutes $seconds
Add Comment
Please, Sign In to add comment