Operating System - HP-UX
1834255 Members
2503 Online
110066 Solutions
New Discussion

Re: using last to show user login/logout

 
SOLVED
Go to solution
kirk_11
Occasional Advisor

using last to show user login/logout

I need to audit user login and logout actions. I want to use the last command to get this information but it does NOT seem to catch login/logout actions from the local terminal - it only seems to be catching telnet login/logouts. Does anyone know how to show all login/logout actions?
don't follow me, I'm lost too...
11 REPLIES 11
Pete Randall
Outstanding Contributor

Re: using last to show user login/logout

Kirk,

Have you tried "last console"?


Pete


Pete
kirk_11
Occasional Advisor

Re: using last to show user login/logout

no I haven't. I would like to get all of the login/logout info - console and telnet
don't follow me, I'm lost too...
Javier Ortiz Guajardo
Frequent Advisor

Re: using last to show user login/logout

take a look at # man wtmp

These files, which hold user and accounting information for such
commands as last, who, write, and login

regards
The obstacles are those things that the people see when they left to see their goals.
Geoff Wild
Honored Contributor

Re: using last to show user login/logout

Strange - last works on my servers (11.0 and 11.i)....what OS version are you running?

gwild ttyq0 Mon Jul 7 14:22 - 14:58 (00:36)
root console Wed Jul 2 11:33 - 11:40 (00:06)


Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
kirk_11
Occasional Advisor

Re: using last to show user login/logout

Thanks for all of the replies already!

The os that I am running is 10.20
don't follow me, I'm lost too...
Pete Randall
Outstanding Contributor

Re: using last to show user login/logout

Kirk,

I'm also on 11.x servers. There seems to be some difference in 10.20 - try "last console" just out of curiosity and see what it says.


Pete


Pete
John Meissner
Esteemed Contributor
Solution

Re: using last to show user login/logout

last -R | sort will give you a good list... also I have a useful script which is attached
All paths lead to destiny
Geoff Wild
Honored Contributor

Re: using last to show user login/logout

Maybe you can make use of .sh_history and logout....

If the user is cshell, then create a .logout - insert comands you want to run - like:

echo `who am i ` " logout on " `date` >>.logout_history

If not cshell, then you could fake it like this:

1. In your .profile file, add the line :

trap ' .$HOME/.sh_logout; exit 0
(Some systems may need $LOGDIR instead of $HOME.)


2. Make a file in your home directory named .sh_logout. Put
in the commands you want to be run when you log out. For example:

clear
echo `who am i ` " logout on " `date` >>.logout_history

The trap will read the .sh_logout file when the shell exits.

Something like the above may work, maybe add a ps /who -u to see what the tty is...

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
kirk_11
Occasional Advisor

Re: using last to show user login/logout

I will be checking these and let you all know what happens.
don't follow me, I'm lost too...
kirk_11
Occasional Advisor

Re: using last to show user login/logout

for those of you who helped me - thanks! The system had a bad real time clock module. I replaced it and magically, the last command seems to behave as expected. I don't quite understand... Anyway, things seem to work...
don't follow me, I'm lost too...
Caesar_3
Esteemed Contributor

Re: using last to show user login/logout

Hello!

Use last: last
you will get info for the user
also you can grep wanted data.

Caesar