Login times...?

Nummi_G4

New Rhapsody User
Is there a way to find out how long a user has been logged in? Over a period of a week/month?
At school we get a monthly report of how long a user was logged in. We have a FreeBSD server and everyone uses Nifty Telnet to login over the network. But I want to able to see this info on my OS X machine at home.

Thanks so much.
 
The command who in the Terminal will show you who's logged in and for how long. The command w will do the same thing, with some additional info. Either will do what you want.
 
Try the shell command last, in the Terminal. It should give you a full report of users' login times.

As with other shell commands, use man last to get more info about it.
 
mmar - only as far back as the wtmp file goes. This is one of the files that gets cleaned by cron once monthly, so you'll only be able to see as far back as the last time the monthly cron job ran. For me, that was yesterday, and as I haven't logged in or out since yesterday, the file is empty (last just displays the text wtmp begins Sun Mar 2 20:09 and nothing else).
 
Darkshadow - You're absolutely right. I forgot that because my iBook isn't usually on at the time those jobs should run... :(

However, the relevant cron job (by default using the script /etc/periodic/monthly/500.monthly in my system) should rotate the wtmp to wtmp.0, wtmp.1, etc, not really clear it...

If you need to retrieve info from these older files you can use last -f <filename> .

Unfortunately, the script also gzips those files (to wtmp.#.gzif) if it finds the gzip executable... In that case, you'll have to gunzip them first...

While checking that out, I also found the following:

That script also uses the ac -p command, which was new to me, but happens to make a nice report with the total time each user spent logged in. If you happen to have sendmail (or any MTA) installed, the output of the script will get sent to your root account by e-mail, every month.

Again, see the relevant (last, cron, ac) man pages for more information.
 
Well, yeah, not really clear it, but not available just by using last is what I meant...

Heh, I added the ac -d and ac -p to my daily.local. The ac -d is supposed to break down the login times in 24 hours chunks, but doesn't really (I've had it list 124 hours for one day...). Also the last 20 logins & reboots with last -20.
 
Regading the ac -d command, it may be summing up the times from different Terminals... Terminal runs a login shell by default, so if you have two running for 1h, they probably add up to 2h logged in time.
 
Back
Top