Few days ago (2014-06-21T10:19:46Z), I was very surprised to discover the --pretty format of uptime, when I ran it with -h, which I never did before:
-p, --pretty show uptime in pretty format -s, --since system up since
Neither had I read uptime(1), it was first times to do both. I was wondering how my dzen status calculated the uptime, which should be from /proc/uptime not uptime command. Anyway, I started to find out when the pretty format was added.
The feature #3e7f78d was added after 2012-02-22 via a pull request1. Here are some outputs of uptime:
$ uptime -p up 1 week, 5 hours, 21 minutes $ uptime -s 2014-06-20 10:51:41 $ date -d "$(uptime -s)" +%s 1403232701 $ echo \ $((($(date +%s) - $(date -d "$(uptime -s)" +%s)) / 3600)) \ hours 173 hours $ td.sh $((($(date +%s) - $(date -d "$(uptime -s)" +%s)))) 7 days 5 hours 22 minutes 36 seconds
The last one uses td.sh, which is actually the main reason why I wondered how my dzen status does the calculation, it uses td.sh to convert seconds into human-readable time duration. At this moment, I am currently in the process to transform it into a C and GNU Autotools learning project, although I havent yet made any progress. Too many things to do, and too little time.
Since we are talking about human-readable and pretty print, you might also want to know we have dmesg --human.
[1] | https://gitorious.org/procps/procps/merge_requests/2/diffs is gone with Gitorious. |
0 comments:
Post a Comment