Last login<urgent>

how to find last login time of a user in faster way if wtmps size is too large??

Last login<urgent>
how to find last login time of a user in faster way if wtmps size is too large??

What wrong with last?

last <user> |head -1

thanks vbe...
but this command takes long time to give the output if we display a list of users with last login value when wtmp is huge..
any other solution???

thanks,
Vishwaraj

Try with -n option it will be probably faster then getting all records

>how to find last login time of a user in faster way if wtmps size is too large??
I though your question was the last login of A user, in such case my command to type should not take more than 4 seconds at the most or you have some trouble (the longest delay I got so far was 1.5!)
I did not say to type last, as this will display all the successfull attempt of all the users since the origin of wtmp, but last <your user name>| head -1 (the first line: the last login) or whatever lines you need or as suggested: last -1 <username> which would be faster still...

Here are some records:

ant:/var/spool/cron/crontabs $ timex last|wc -l

real 16.32
user 9.40
sys 1.55

182882
ant:/var/spool/cron/crontabs $ timex last vbe|head -1
vbe pts/1 Thu Jan 31 16:26 - 16:33 (00:06)

real 0.42
user 0.19
sys 0.08

ant:/var/spool/cron/crontabs $ timex last -1 vbe
vbe pts/1 Thu Jan 31 16:26 - 16:33 (00:06)

real 0.03
user 0.01
sys 0.01

With 182882 records it replies (almost) instantly...

No doubt last -1 name is the fatest...

I suggest that you resize wtmp at something reasonable if it is giving you trouble... ( save a copy before for archive history... since you can use last specifying a filename also! great no?)

If you have may users you want the information write a script that read the list of names

All the best

thanks a lot vbe :slight_smile:

got an idea...
i'l try it by writing a script for the names of all users...

thanks,
vishwaraj