Skip to content

Instantly share code, notes, and snippets.

@johnmurch
Created July 27, 2016 14:15
Show Gist options
  • Save johnmurch/8b71019102ae27309cffbe5229580cd3 to your computer and use it in GitHub Desktop.
Save johnmurch/8b71019102ae27309cffbe5229580cd3 to your computer and use it in GitHub Desktop.
Bash Uptime
#!/bin/bash
# uptime.sh
# get uptime from /proc/uptime
uptime=$(</proc/uptime)
uptime=${uptime%%.*}
seconds=$(( uptime%60 ))
minutes=$(( uptime/60%60 ))
hours=$(( uptime/60/60%24 ))
days=$(( uptime/60/60/24 ))
echo "$days days, $hours hours, $minutes minutes, $seconds seconds"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment