- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Determining last user logon
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
Forums
Discussions
Discussions
Discussions
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
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
10-18-2004 05:03 AM
10-18-2004 05:03 AM
Is there any way to use the u_suclog field in the tcb encrypted file or ANY other way to determine for each user in /etc/passwd when their last logon was? We are going to use this for clean up purposes on the system..... Any assistance is GREATLY appreciated..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2004 05:10 AM
10-18-2004 05:10 AM
Re: Determining last user logon
you can use command for each user:
last user_name | head -n1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2004 05:10 AM
10-18-2004 05:10 AM
Re: Determining last user logon
I've merged the output of "last" with "/etc/passwd" via a perl program and have generated such lists for myself.
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2004 05:14 AM
10-18-2004 05:14 AM
Re: Determining last user logon
last
will show it.
If not, passwd -sa might provide some useful data or some other variation, though this may only show the last time they changed their password. That isn't useless, may be helpful.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2004 05:16 AM
10-18-2004 05:16 AM
Re: Determining last user logon
last userid |head -1
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2004 05:19 AM
10-18-2004 05:19 AM
Solution#!/usr/local/bin/perl
# Show last logins for every user in /etc/passwd
#
open(LASTLOGIN,"last|") || die "Can not run 'last' command\n";
while (
next if $_ eq "";
if (/^wtmp begin/) {$begin=$_ ; next};
($name,$tty,$date)=/(\S+)\s+(\S+)\s+(\S+\s+\S+\s+\S+)/;
$user{$name}=$date unless $user{$name};
}
print $begin;
close(LASTLOGIN);
open(PASSWD,"/etc/passwd") || die "Can not open '/etc/passwd'\n";
while (
next if /^\+/;
($name,$rest)=split(":");
$user{$name}="**NOT USED**" unless $user{$name};
}
foreach $name (sort keys(%user)) {
printf "%-10s %s\n",$name,$user{$name};
}
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2004 06:08 AM
10-18-2004 06:08 AM
Re: Determining last user logon
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2004 06:28 AM
10-18-2004 06:28 AM
Re: Determining last user logon
next if /^\+/;
This statement skips those lines that begin with "+". What ever regular expression can be used. Example-
To ignore users who are using ksh.
next if /bin\/ksh/;
You could also replace the follwing split statement with-
($user,$pswd,$uid,$gid,$comment,$path,$shell)=split(":",$_);
Then do comparisons on the a field-
next unless $comment=~/test/;
Would only keep entries with "test" in the comment field (note "unless" clause).
Perl is the swiss army knife for system admins.
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2004 06:34 AM
10-18-2004 06:34 AM
Re: Determining last user logon
# /usr/lbin/getprpw -m ulogint user_id
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2004 07:01 PM
10-18-2004 07:01 PM
Re: Determining last user logon
you can use shell script:
#!/bin/sh
for user in `cat /etc/passwd | awk -F':' '{print $1}'`
do
RES=`last $user | head -n1`
[ "$RES" = "" ] || echo $RES
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2004 10:47 AM
10-19-2004 10:47 AM