LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to get user login time (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-get-user-login-time-702316/)

haplo 02-04-2009 02:36 PM

how to get user login time
 
Hello, could someone tell me how to get each a user's login time on a linux system(meaning the time between his last login and the present or between his last login and the time when he left, if he's not logged currently). I've already tried finger and last but they only give me the date of the login or the interval.

pentode 02-04-2009 03:05 PM

Not sure, but auth.log should have the log-in and log-out times.

ncsuapex 02-04-2009 03:35 PM

you can do:

last | grep username

mrclisdue 02-04-2009 03:41 PM

Quote:

Originally Posted by ncsuapex (Post 3432331)
you can do:

last | grep username

Exactly, but the OP claims that the last command doesn't give him this info. It certainly works for me, tho'
Code:

*****    pts/5        :pts/3:S.0      Wed Feb  4 06:09 - 06:30  (00:20)   
*****    pts/5        :pts/3:S.0      Tue Feb  3 05:02 - 06:02  (01:00)   
*****    pts/5        spare_room      Mon Feb  2 20:49 - 21:06  (00:17)   
*****    pts/5        :0.0            Mon Feb  2 16:52 - 16:52  (00:00)   
*****    pts/3        :0.0            Mon Feb  2 11:03  still logged in 
*****    pts/3        :0.0            Mon Feb  2 10:57 - 11:03  (00:05)   
*****    pts/3        :0.0            Mon Feb  2 10:55 - 10:57  (00:02)   
*****    pts/2        :0.0            Mon Feb  2 10:05  still logged in 
*****    pts/0        :0.0            Mon Feb  2 08:15  still logged in 
*****    pts/3        :pts/1:S.0      Mon Feb  2 06:33 - 06:50  (00:16)   
*****    pts/5        :0.0            Sun Feb  1 10:16 - 05:39  (19:22)   
*****    pts/4        :0.0            Sun Feb  1 10:15 - 10:16  (00:01)   
*****    pts/3        :pts/2:S.0      Sun Feb  1 10:09 - 10:46  (00:37)   
*****    pts/3        :pts/2:S.0      Sun Feb  1 08:04 - 08:29  (00:24)


cheers,

haplo 02-05-2009 02:01 AM

Oh, I see, I thought the info in round brackets after the login interval were minutes and seconds so i ignored it. Pretty stupid thing to do ,really. Thank you for the quick replies, that solves half of the problem. I stil notice that the users that are still logged on don't have the login duration up to the current time calculated. Isn't there a way to get that too?


All times are GMT -5. The time now is 08:37 PM.