Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 02-08-2005, 09:09 AM   #1
LQ Newbie
Registered: Dec 2004
Posts: 11

Rep: Reputation: 0
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 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 advance
Old 02-08-2005, 09:55 AM   #2
Senior Member
Registered: Feb 2004
Location: Somerset, England
Distribution: Slackware 10.2, Slackware 10.0, Ubuntu 9.10
Posts: 1,938

Rep: Reputation: 55
'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.
Old 02-08-2005, 12:40 PM   #3
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 927Reputation: 927Reputation: 927Reputation: 927Reputation: 927Reputation: 927Reputation: 927Reputation: 927
Have a look at the output of

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



Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Control amount of time a user may be logged in. (Parental Control) darrensnospam Mandriva 13 02-18-2006 06:01 PM
Calculate in shell script Ephracis Linux - General 1 12-16-2004 12:11 PM
strange request: script to track logged in time hamster Linux - General 3 05-08-2003 01:52 PM
mozilla works fine when logged in as a user but crashes when logged in as root jimi Linux - General 6 04-02-2003 09:34 PM
Remote message: User: already logged onto system 1 time(s). jamaso Linux - General 1 11-08-2002 06:08 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:20 AM.

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