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

Solaris 'last' command

Status
Not open for further replies.

BIS

Technical User
Jun 1, 2001
1,893
NL
Hallo Experts,

I would dearly love some suggestions on how to accomplish this. I need to create a log file of last logins. I have found the 'last' command to have enough information for my needs. The problem is that the output of this command seems to get overwritten, i.e. it only contains the last week or so. My idea was to have cron output the details of 'last' to a file, say every three days. The problem I have is that if I do this (for ex. 0 0 * * 1,3,6 /usr/bin/last >>/file/to/append/to ) there will be duplicate entries. Is there any way to avoid this with a script (perhaps using 'diff'), or a neater, simpler solution?
Many thanks for any input.
 
Not entirely sure what you're trying to achieve, but after running last, you could clear down /var/adm/wtmpx to avoid duplicate entries (cat /dev/null > /var/adm/wtmpx)

Greg.
 
BIS,

How about using last | sort -u which displays only unique lines (no duplicates).

John
 
The only problem is that it takes the input and sorts it alphabetically, thus removing the chronological order. You will likely have to re-sort the output depending on the results you are looking for.

John
 
What version of Solaris are you running? In my experience, the output of the last command will date all the way back to system install if you don't clean /var/adm/wtmpx.
 
This is SunOS 5.7 - and I am definitely sure that I only get a week or so - as grega said there must be a limit to the wtmpx file.I kind of like the cat /dev/null > /var/adm/wtmpx idea though...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top