Operating System - HP-UX
1751693 Members
4981 Online
108781 Solutions
New Discussion юеВ

Re: how to create a list of users that didn't logon for the past 6 months?

 
SOLVED
Go to solution
Bhadresh
Trusted Contributor

Re: how to create a list of users that didn't logon for the past 6 months?

Kelvin Ng
Advisor

Re: how to create a list of users that didn't logon for the past 6 months?

Thanks guys, i managed to find those users account that has not been login for past 3 months.

Regards,
Kelvin
Dennis Handly
Acclaimed Contributor

Re: how to create a list of users that didn't logon for the past 6 months?

>JRF: One simplistic way to find the users who haven't logged in is to use "last name"

Yes but very slow and it will have to read the file for each user.
James R. Ferguson
Acclaimed Contributor

Re: how to create a list of users that didn't logon for the past 6 months?

Hi (again):

> Dennis: Yes but very slow and it will have to read the file for each user.

Yes, of course. That's why i used the word "simplistic". For performance, I'd probably use a Perl hash (associative array) to hold the account names seen by running 'last()' once. Then, walk '/etc/passwd' testing each account name for its presence in the hash. Existence in the hash means that the account has had activity, so skip reporting it. The absence of an account in the hash signifies a user without activity and that's a name to list.

Regards!

...JRF...
Hakki Aydin Ucar
Honored Contributor

Re: how to create a list of users that didn't logon for the past 6 months?

it is good idea to use in Perl arrays, OR more easier in not busy hour of system they can be collected with a cronjob ,preferably after midnight like ;

# last > /tmp/last.file ## This run inside cron
# cat /tmp/last.file |awk '{print $1,$3,$4,$5}'| grep -E 'User_We_Look_For|Jun 23'

just an idea derived from JRF 's idea..