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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need help with a script 4

Status
Not open for further replies.

rejohn

Technical User
Jun 23, 2004
21
US
I need to identify user accounts that haven't been accessed in 24 months.
 
How many different places are you gonna post this request?
Can you not wait two minutes for someone to respond?



Trojan.
 
Look at the [tt]lastlog[/tt] and [tt]comm[/tt] commands. Maybe something like this...
Code:
lastlog -t 365 | awk '{print $1}' | tail +2 | sort > /tmp/last12mo.$$.tmp

cut -d: -f1 /etc/passwd | sort > /tmp/allusers.$$.tmp

echo "The following users haven't logged in for more than 12 months"
echo "-------------------------------------------------------------"
comm -13 /tmp/last12mo.$$.tmp /tmp/allusers.$$.tmp

rm /tmp/*.$$.tmp
This first makes a list of everyone who has logged in within the last 365 days (12 months). Then it makes a list of all users. Then it uses [tt]comm[/tt] to subtract the users who have logged in from the whole user list. There might be an easier way, but this is a quick-and-dirty.

Hope this helps.
 
rejohn : I think you must have posted this on the wrong site - we are here to help professionals who ask questions politely, and at least *attempt* to have solved problems befor posting. Often we hope that the poster has attempted to solve their problem themselves, and lets us know their attempted solutions.

You obviously meant to send this curt phrase to your account administrator or support.


--------------------------------------------------
Free Java/J2EE Database Connection Pooling Software
 
SamBones: nice quick-and-dirty. I hadn't heard of 'comm' before. Nifty tool there, thanks!

----
JBR
 
Just did "man comm" myself for the first time.
Live and learn. Chalk one up for bash in the bash vs. perl debate.

D.E.R. Management - IT Project Management Consulting
 
Yeah, I remember the day I discovered [tt]comm[/tt]. The clouds parted and sunlight filled the room. Angels sang.

It's VERY useful for all those file comparisons where you need the records that are in one file and not the other, or unique records, or common records.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top