If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > how long was a user connected

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-13-04, 12:59
ceci ceci is offline
Registered User
 
Join Date: Apr 2004
Posts: 3
Question how long was a user connected

hi, I need to know how long a user is connected to the server, so at any time I can tell how many hours he was connected since a given date.

as far as I got was to get the date the user logged in and the date he got out. I put this on the .logout file, so I get two lines (login date/time and logout date/time) everytime the user connects. this is just the output of the `who am i` command and the date the user exists the system, but I have no clue of how to calculate the time between these two dates. any help please??
Reply With Quote
  #2 (permalink)  
Old 04-15-04, 13:25
Hobbletoe Hobbletoe is offline
Registered User
 
Join Date: Mar 2004
Posts: 3
Try using the last command. When you use it, you get who logged in, where they logged in from, when the logged in, when they logged out, and for how long they were logged in. If they were logged in for five minutes, the last column would be (00:05). If they were logged in for an hour and five minutes, the last column would be (01:05). If they were logged in for a day and five minutes, you would see (1+00:05).

Of course, used with grep, you can pull out just a given user, and not get the entire list of folk. You'll need a parser, or an awk script to pull the data out and give you an actual time though, and unfortunately, I don't have the time to do it just now (meetings ... blah), but will see what I can get if no one else gets to it first.

Hobbletoe
Reply With Quote
  #3 (permalink)  
Old 04-15-04, 14:40
ceci ceci is offline
Registered User
 
Join Date: Apr 2004
Posts: 3
I'll give it a try. Thanks a lot!!!!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On