print statistics about users' connect time

ac -d | awk '{h=int($NF); m=($NF-h)*60; s=int((m-int(m))*60); m=int(m); print $0" = "h"h "m"m "s"s "}'
'ac' is included in the package 'acct', which is described as "The GNU Accounting utilities for process and login accounting". Other interesting flags are: * print statistics for a specified user ac -d username * print statistics for all the users ac -p With my command, the output is also printed in a sexagesimal, more readable, style.
Sample Output
Jun  2	total       46.46 = 46h 27m 36s 
Jun  3	total       59.86 = 59h 51m 35s 
Jun  4	total       81.64 = 81h 38m 24s 
Jun  5	total       73.41 = 73h 24m 35s 
Jun  6	total       19.80 = 19h 48m 0s 
Jun  7	total       43.26 = 43h 15m 35s 
Jun  8	total       54.47 = 54h 28m 11s 
Jun  9	total       76.59 = 76h 35m 24s 
Jun 10	total       92.50 = 92h 30m 0s 
Jun 11	total       46.75 = 46h 45m 0s 
Jun 12	total       30.66 = 30h 39m 36s 
Jun 13	total       40.65 = 40h 38m 59s 
Jun 14	total       60.08 = 60h 4m 47s 
Jun 15	total       75.36 = 75h 21m 35s 
Jun 16	total       87.57 = 87h 34m 11s 
Jun 17	total       83.92 = 83h 55m 12s 
Jun 18	total       93.14 = 93h 8m 24s 
Jun 19	total      105.85 = 105h 50m 59s 
Jun 20	total       51.03 = 51h 1m 48s 
Jun 21	total       36.27 = 36h 16m 12s 
Jun 22	total       76.69 = 76h 41m 23s 
Jun 23	total       52.55 = 52h 32m 59s 
Today	total       29.55 = 29h 33m 0s 

By: karpoke
2010-06-24 08:08:41

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this? is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands

Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.


Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: