- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- last and finger command
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2005 06:11 AM
тАО09-15-2005 06:11 AM
last and finger command
Sometimes finger gives the output тАЬNever logged inтАЭ (for which last does not give any output at all). In that case how do I know this is true since when? My understanding is that these commands get this information from wtmp file. How can I know what is the earliest date this file has the data? I have seen the very last command for last is something like this тАЬwtmp begins Mon Feb 16 16:17тАЭ. Again there is no Year there.
Any help would be appreciated
Thanks
Suresh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2005 06:14 AM
тАО09-15-2005 06:14 AM
Re: last and finger command
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2005 06:17 AM
тАО09-15-2005 06:17 AM
Re: last and finger command
Don't know all options that can be used with last but you can always have a look at "man last" and "man finger"
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2005 06:55 AM
тАО09-15-2005 06:55 AM
Re: last and finger command
I understand the issue with the YEAR and that is not a problem. I can get that from finger.
The question I have now is how can I get the starting date of this login information data the system keeps in wtmp or something like that. that has nothing to do with a single user. But is the oldest date the system has the login information.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2005 07:03 AM
тАО09-15-2005 07:03 AM
Re: last and finger command
You are correct, 'last' reports its dates *without* any year. The data, indeed, comes from /var/adm/wtmp.
The initial heading from a 'last' query does (at least) identify the date at which the file begins. That is, if you redirect /dev/null to /var/adm/wtmp to clear it, then the date and time at which you do that is reflected in 'last's "begins..." announcement.
It is generally expected that you will periodically null the 'wtmp' file so that it doesn't grow without bound.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2005 07:17 AM
тАО09-15-2005 07:17 AM
Re: last and finger command
HOWEVER, you can periodically convert your /var/adm/wtmp file from a binary file to an ASCII one; save it and truncate the current 'wtmp' binary file.
The advantage for you is that the ASCII version expands the timestamp into a full date with the year.
# /usr/sbin/acct/fwtmp < /var/adm/wtmp > mylogindb
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2005 08:21 AM
тАО09-15-2005 08:21 AM
Re: last and finger command
# this is the template we're going to feed to unpack( )
$template = "A8 A4 A12 l s s s s l a16 l";
# this uses pack( ) to help us determine the size (in bytes)
# of a single record
$recordsize = length(pack($template,( )));
# open the file
open(WTMP,"/var/adm/wtmp") or die "Unable to open wtmp:$!\n";
# read it in one record at a time
while (read(WTMP,$record,$recordsize)) {
# unpack it, using our template
($user,$ttyid,$tty,$pid,$type,$term,$exit,$time,$host,$hostip)=unpack($template,$record);
next unless $type == 7;
next unless $ttyid;
next if $ttyid eq "ftp";
next if $ttyid=~/\d+:\d+/;
$user=~y/\000//d;
$ttyid=~y/\000//d;
$tty=~y/\000//d;
$host=~y/\000//d;
print join(",",$user,$ttyid,$tty,$pid,$time,$host),"\n";
}
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2005 04:42 PM
тАО09-15-2005 04:42 PM
Re: last and finger command
date >> log_file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-15-2005 05:06 PM
тАО09-15-2005 05:06 PM
Re: last and finger command
echo `who -mu;date +'%Y'` | awk '{ print $1,$2,$3,$4,$9,$5 }' >> /var/adm/login.log
hth.