LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   shell script to calculate the time a user is logged in (https://www.linuxquestions.org/questions/linux-newbie-8/shell-script-to-calculate-the-time-a-user-is-logged-in-287648/)

racer_mec 02-08-2005 08:09 AM

shell script to calculate the time a user is logged in
 
hello ,
i am trying to write a shellscript which will provide the name ,logged in time , logout time and total time for all the users accessing a particular machine..how do i do this...with the last command i got many details..can i extract te needed values from the output of this command..please help..
thanks in advancehttp://www.linuxquestions.org/questions/newthread.php?s=&action=newthread&forumid=8#

Komakino 02-08-2005 08:55 AM

'who' will tell you who is logged in and what time they logged in. Not sure about logout time though. You could use last and pipe the output through awk which will let you extract the fields using $1 $2 $3 etc for each field.

Tinkster 02-08-2005 11:40 AM

Have a look at the output of
last

Depending on how (whether) you shut down the
box it will provide reasonably accurate time info
for users ...


Cheers,
Tink


All times are GMT -5. The time now is 08:44 PM.