Operating System - HP-UX
1826933 Members
2321 Online
109705 Solutions
New Discussion

Last time a person logged in

 
SOLVED
Go to solution
Jay_122
Advisor

Last time a person logged in

Is there any script that will tell me that last time users defined in the password file logged in? I am familiar with the last command, but our wtmp file has data from more then a year ago and we have a lot of users in the password file. So I was hoping that there was a script to wade through and list the most recent login.

5 REPLIES 5
James A. Donovan
Honored Contributor

Re: Last time a person logged in

No script, but it's easy to do.

$ last|grep username|head -n 1

will give you the most recent.
Remember, wherever you go, there you are...
Jay_122
Advisor

Re: Last time a person logged in

Thanks
Patrick Wallek
Honored Contributor
Solution

Re: Last time a person logged in

Try this little script:

for USER in $(cat /etc/passwd | awk -F : '{print $1}'
do
LOGIN=$(last ${USER} | head -1)
echo ${LOGIN} >> /tmp/last_logins
done
Patrick Wallek
Honored Contributor

Re: Last time a person logged in

Try this little script:

for USER in $(cat /etc/passwd | awk -F : '{print $1}')
do
LOGIN=$(last ${USER} | head -1)
echo ${LOGIN} >> /tmp/last_logins
done
Jay_122
Advisor

Re: Last time a person logged in

Thanks for all the help