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

User report 1

Status
Not open for further replies.

smith364

IS-IT--Management
Jun 26, 2001
34
US
I am trying to use the lsuser -a command to list all of the users last successful and unsuccessful login. I also want the date and time. How do I format the information like the login stanza. I want this information in a report format. I am writing a script but cannot capture the date the way I want it. Does anyone have a script that will do this?

Thank you
 
The information you're looking for is in /etc/security/lastlog. Download perl script 'sec2date' to convert the timestamps to to default date format. Keep in mind that for dates after Feb. 28 2000, the date shown is off by one day, because year 2000 was not a leap year. Also the date and time are GMT.
 
Hi,

Mybe you can also use command last for this purpose
man last for more infos

Ali
 

Sorry, I don't have time to write this one up. Seems like a fun one.... Maybe this will get you started.

I think I would do something like this (psuedo code):

for vuser in $(lsuser -a ALL)
do

vuser_line= grep for $vuser (returning line #) - lastlog
vlast_success_line = $vuser_line + 1
vlast_fail_line = $vuser_line + 3

awk for line num returning only your values (column #)

covert values to your time zone

display values to a file formatted however you want

done
 
Here's a quick and dirty that automatically deals with leap days and timezone:

Code:
lsuser -f -a time_last_login time_last_unsuccessful_login ALL |\
 perl -p -e 's/=(\d+)/sprintf("= %s",scalar localtime $1)/e'

Rod Knowlton
IBM Certified Advanced Technical Expert pSeries and AIX 5L
CompTIA Linux+
CompTIA Security+

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top