26 lines
596 B
Bash
Executable file
26 lines
596 B
Bash
Executable file
#!/bin/sh
|
|
|
|
# Always print uptime in three columns.
|
|
# Two case; case time < 1d, print h m s
|
|
# case time > 1d, print d h m
|
|
|
|
time=$(cat /proc/uptime)
|
|
time="${time%%.*}"
|
|
|
|
|
|
if [ ${time} -ge 86400 ]
|
|
then
|
|
day=$(($time / 86400))
|
|
time=$((${time} - day * 86400))
|
|
hour=$(($time / 3600))
|
|
time=$(($time - hour * 3600))
|
|
minutes=$(($time / 60))
|
|
time=$((time - minutes * 60))
|
|
echo "${day}d ${hour}h ${minutes}m"
|
|
else
|
|
hour=$(($time / 3600))
|
|
time=$(($time - hour * 3600))
|
|
minutes=$(($time / 60))
|
|
time=$((time - minutes * 60))
|
|
echo "${hour}h ${minutes}m ${time}s"
|
|
fi
|