Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need To get a list of users that havent loged in in 6 months, 1

Status
Not open for further replies.

Genka

MIS
Jul 15, 2001
20
0
0
US
I need to get a list of users that have not loged in more then 6 months ago, I though that maybe I can check the .profile of all the users, since .profile changes its date when a user logs in. Would any one have a script that I can use.
 
Could be tricky. This command will list the last login time of all users. You could adapt it into a script if you like.
Code:
for i in `cat /etc/passwd|cut -d":" -f1`
do
last -n 1 $i
done | grep -v begins | grep -v "^$"
[code]
[b]last -n 1 username[/b] displays the last 1 login of the specified user. The 2 greps at the end are just to tidy up the output.

Greg.
 
Greg, Thanks, I tried running the script but having problem running it, spits this out when i do
usage: last [ -number ] [ -f file] [ -R ] [ name ... ] [ tty ... ]
 
It looks like the syntax of the last command is different on your platform (I'm on Solaris 2.6). Try this ...

last -1 $i

If that doesn't work, do a man last to check the exact syntax of the command.

Greg.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top