Hack 28. Display total connect time of users

by Ramesh

Ac command will display the statistics about the user’s connect time.

Connect time for the current logged in user

With the option –d, it will break down the output for the individual days. In this example, I’ve been logged in to the system for more than 6 hours today. On Dec 1st, I was logged in for about 1 hour.

  1. $ ac d
  2.  
  3. Dec 1 total 1.08
  4. Dec 2 total 0.99
  5. Dec 3 total 3.39
  6. Dec 4 total 4.50
  7. Today total 6.10

Connect time for all the users

To display connect time for all the users use –p as shown below. Please note that this indicates the cumulative connect time for the individual users.

  1. $ ac -p
  2.  
  3. john 3.64
  4. madison 0.06
  5. sanjay 88.17
  6. nisha 105.92
  7. ramesh 111.42
  8. total 309.21

Connect time for a specific user

To get a connect time report for a specific user, execute the following:

  1. $ ac -d sanjay
  2.  
  3. Jul 2 total 12.85
  4. Aug 25 total 5.05
  5. Sep 3 total 1.03
  6. Sep 4 total 5.37
  7. Dec 24 total 8.15
  8. Dec 29 total 1.42
  9. Today total 2.95