add newuptime
This commit is contained in:
parent
bd34aeeeca
commit
42a6b8052c
1 changed files with 26 additions and 0 deletions
26
newuptime
Executable file
26
newuptime
Executable file
|
@ -0,0 +1,26 @@
|
|||
#!/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
|
Loading…
Reference in a new issue