1838656 Members
3617 Online
110128 Solutions
New Discussion

last login format

 
Cifs 9000
Advisor

last login format

when i execute last command i got this
solisds pts/ta Mon Nov 27 09:31 - 09:33 (00:01)

How to know which year.
Please let me know.
please provide me script or command .

like that , i can see the year

Last successful login for dave: Mon Sep 17 18:36:58 GMT 2001
4 REPLIES 4
Dennis Handly
Acclaimed Contributor

Re: last login format

>How to know which year?

This may be similar to ls(1)? If in the last 6 months, it leaves the year off.
I'm not sure if the "-x" option for long formats would give you more info?
James R. Ferguson
Acclaimed Contributor

Re: last login format

Hi:

The 'wtmps' file ('/var/adm/wtmp') actually contains a "full" date --- in epoch seconds. Thus, it is only the output of 'last' which suppresses the year display.

You can convert the binary 'wtmp' file to an Ascii one for parsing or viewing with:

# /usr/sbin/acct/fwtmp < /var/adm/wtmp

Regards!

...JRF...
Bill Hassell
Honored Contributor

Re: last login format

And to followup with the no-year display -- it is not a good idea to keep /var/adm/wtmp (the source for the last command) more than 6 to 9 months. Instead, the wtmp (and btmp) files should be archived bi-yearly during your patch window. The commands: last, lastb and who are highly unstable when the wtmp file is corrupted and with more than 1 year's worth of data, these commands will report what seem to be ghost sessions which are actually more than a year ago.


Bill Hassell, sysadmin
Dennis Handly
Acclaimed Contributor

Re: last login format

I wasn't able to get anything useful out of -x. And the note about using -X and -f wasn't helpful.