This recipe makes use of the system logs to find out how many hours each user has spent on the server and ranks them according to the total usage hours. A report is generated with the details, including rank, user, first logged in date, last logged in date, number of times logged in, and total usage hours.
Determining active user hours on a system
Getting ready
The raw data about user sessions is stored in a binary format in the /var/log/wtmp file. The last command returns details about login sessions. The sum of the session hours for each user is that user's total usage hours.
How to do it...
This script will...