LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices

Tags used in this thread
Popular LQ Tags , ,

Reply
 
Thread Tools
Old 09-30-2009, 08:31 AM   #1
hiarunn
LQ Newbie
 
Registered: Apr 2006
Posts: 7
Thanked: 0
How to track the user sessions


[Log in to get rid of this advertisement]
I'm using LDAP and kerberos for user authentication. All I want to know is how to track the users currently logged on from a common location. I was thinking of having a script to write the $USER,$HOSTNAME,login/logout time, hours used etc on a NFS mount, but don't know where to call the script so that it will be executed whenever an user logs in / logs out. I'm using Gnome desktop manager.

Thanks in advance.

--
Arun
linuxredhat hiarunn is offline  
Tag This Post , ,
Reply With Quote
Old 09-30-2009, 09:54 PM   #2
half_life1052
LQ Newbie
 
Registered: Jul 2008
Posts: 1
Thanked: 0
If you want to track who is logged in to your machine, just use the "w" command. To keep it updating you would use a command such as "watch -n2 w". This will show who is logged in, and what they are doing. It will update every 2 seconds "-n2" . To find out historically who has logged in, the "last" command will help you.
linuxubuntu half_life1052 is offline     Reply With Quote
Old 10-01-2009, 01:00 AM   #3
hiarunn
LQ Newbie
 
Registered: Apr 2006
Posts: 7
Thanked: 0

Original Poster
The command "w" or "last" is useful when you want to know who is currently logged into a particular system. But in my setup there are 250+ workstations. I should be able to see who logged into to each system. The output of the script/cmd should be something like below

Host User Login_time logout_time
------------------------------------
host1 userA 10:30 Still logged in
host2 userB 09.15 12:10
host3 userX 11.30 Still logged in

This should get updated everytime a user login/logout.
linuxredhat hiarunn is offline     Reply With Quote
Old 10-07-2009, 09:02 AM   #4
hiarunn
LQ Newbie
 
Registered: Apr 2006
Posts: 7
Thanked: 0

Original Poster
I found the way to do this. I wrote a simple shell script to log the hostname, user name and login/logout time to a plain text file and append the lines to /etc/X11/gdm/PostLogin/Default file to log when a user logs in and /etc/X11/gdm/PostSession/Default can be used when a user quits the session. The information can be directed to a text file on the network mount or to a remote database.
linuxredhat hiarunn is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get a Bash to count user sessions without WC Bamahut Programming 5 07-16-2008 07:52 AM
record of user sessions PirateJack Linux - Newbie 5 04-03-2006 03:25 PM
how to track all the live sessions in php? xudingding Linux - Software 3 02-15-2006 11:55 AM
track sudo user mikeshn Linux - General 2 10-28-2003 08:12 PM


All times are GMT -5. The time now is 10:18 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration