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

Log off tracking 1

Status
Not open for further replies.

lorel

MIS
Jun 15, 2004
158
Hi there!
Need to write a script that will detect when a user log off and exits the system. I need to get this info and put it in a file. I have been unable to find were to put my code to get this info. Can any one help?

Like always, Thanks

Joe

PD Using SCO 5.0.7
 
I don't have a SCO box to check any more, but doesn't the last command show you when people logged off?

Annihilannic.
 
The last command does shows when the user log off, but what I need to do is create a database that will keep a historical listing on when an user logged in and logged out. The login part is taken care off, but I have been unable to find were I can put some code to catch the moment the user log off.
I could read the results of the last command an extract the info from it, but, since it has to be run frequently, it would put to much of a burden on the system.

In any case, thank you for taken the time to type a replay to my question.

Joe
 
You may try this in the user's profile:
trap 'echo "`date` `id` logout" >> /path/to/logfile' 0

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV:

I had a similar line in the .profile that looks like this:

echo "$MYENV2" `date '+Date: %m/%d/%y Julian: %y%j Time: %r' "log off" >> /u/ulog/userlog

This line did more or less worked but, it duplicate the entry when we needed to cancel the user due to a hang up condition. I added the trap and the 0 at the end of the line plus the ticky marks, now when I login as an user I get "-sh %m wrong number"

If I use your line as you typed it then it work find, but I need the Julian number in order to do the search for the user by date.

I am sure that the problem has to do with the ticky marks, maybe I am using then incorrectly.
The way I am typing the line is like this:
trap 'echo "$MYENV2" `date '+Date: %m/%d/%y Julian: %y%j Time: %r'` "log off" >> /u/ulog/userlog' 0

Could you help me with this?

Again I like to thank you for your invaluable advise

Joe
 
trap 'echo "$MYENV2" `date "+Date: %m/%d/%y Julian: %y%j Time: %r"` "log off" >> /u/ulog/userlog' 0

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thank you PHV, replacing the ' for the " did the trick

Thank you again

Joe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top