LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices


Reply
  Search this Thread
Old 05-08-2017, 02:15 AM   #1
infoobayo
LQ Newbie
 
Registered: May 2017
Posts: 1

Rep: Reputation: Disabled
Time


Please, I need help. I need a code to display
" Benn Franklin is logged on to terminal pts/13 and has been for 1 hour(s) and 17 minute(s)". I know how to get user's name and terminal but I don't know how to get how long the user has been on (will not exceed 24 hours)

NOTE: the system displays time using a 24-hour military style clock format.

Last edited by infoobayo; 05-08-2017 at 02:16 AM.
 
Old 05-08-2017, 03:25 AM   #2
mrmazda
Senior Member
 
Registered: Aug 2016
Location: USA
Distribution: openSUSE, Debian, Knoppix, Mageia, Fedora, others
Posts: 3,267
Blog Entries: 1

Rep: Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102Reputation: 1102
Is this for a homework assignment for school? I hope it's not. You might try adapting the instructions that Google found when I searched, expecting to find something simpler.
 
Old 05-08-2017, 03:56 AM   #3
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,510

Rep: Reputation: 5552Reputation: 5552Reputation: 5552Reputation: 5552Reputation: 5552Reputation: 5552Reputation: 5552Reputation: 5552Reputation: 5552Reputation: 5552Reputation: 5552
echo '" Benn Franklin is logged on to terminal pts/13 and has been for 1 hour(s) and 17 minute(s)"'
will do that.
 
2 members found this post helpful.
Old 05-08-2017, 06:29 AM   #4
Jjanel
Member
 
Registered: Jun 2016
Distribution: any&all, in VBox; Ol'UnixCLI; NO GUI resources
Posts: 999
Blog Entries: 12

Rep: Reputation: 363Reputation: 363Reputation: 363Reputation: 363
Welcome to LQ. BUT please read this (my favorite 'How To'):
http://www.linuxquestions.org/questi...ml#post5669556

A web-search of your question would have been more efficient and faster:
linux command how long user has been logged in

Here's a sample result, in a book I liked.

Last edited by Jjanel; 05-08-2017 at 07:32 AM.
 
Old 05-08-2017, 06:41 AM   #5
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,319
Blog Entries: 13

Rep: Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372
Quote:
Originally Posted by infoobayo View Post
Please, I need help. I need a code to display
" Benn Franklin is logged on to terminal pts/13 and has been for 1 hour(s) and 17 minute(s)". I know how to get user's name and terminal but I don't know how to get how long the user has been on (will not exceed 24 hours)

NOTE: the system displays time using a 24-hour military style clock format.
Hi infoobayo and welcome to LQ.

As some of my fellow members have asked or implied, "What have you tried?"

You're asking for code, a handout. We are all volunteers, including yourself.

What code do you know? Are you thinking to use a script or a compiled program? Do you have any idea how to start a script at all? If you wrote a script, are you familiar with what you need to accomplish in order to be able to run the script?

Homework questions are fine on LQ, if you do identify that you are working on one and also do not post the question verbatim. Further, if it is homework, you really should be attempting this on your own and sharing your thoughts about it, as well as how close or far you are to any possible answer. This is very fundamental stuff, and if you are so very far from any possible solution, you need help and should seek it from your instructor. If this is for work or self exploration, we fully understand this, and our intentions are that you learn these fundamental things correctly so that you do not end up asking for a code handout as your next question, but instead have a problem where you are able to demonstrate your initial efforts and can possibly also help other future members with problems similar to ones which you do know the answer.
 
Old 05-08-2017, 09:21 AM   #6
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 9,154
Blog Entries: 4

Rep: Reputation: 3232Reputation: 3232Reputation: 3232Reputation: 3232Reputation: 3232Reputation: 3232Reputation: 3232Reputation: 3232Reputation: 3232Reputation: 3232Reputation: 3232
man who
 
Old 05-08-2017, 11:58 AM   #7
jamison20000e
Senior Member
 
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US( + travel,) Earth( I wish,) END BORDER$!◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that works well on my cheapest; has been KDE or CLI but open... http://goo.gl/NqgqJx &c ;-)
Posts: 4,397
Blog Entries: 3

Rep: Reputation: 1436Reputation: 1436Reputation: 1436Reputation: 1436Reputation: 1436Reputation: 1436Reputation: 1436Reputation: 1436Reputation: 1436Reputation: 1436
Talking

Click image for larger version

Name:	rtfm.gif
Views:	26
Size:	78.5 KB
ID:	24964
 
Old 05-08-2017, 04:13 PM   #8
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873Reputation: 873
/var/log/auth.log has some of that information. Although root:adm in debian.
 
Old 05-08-2017, 09:46 PM   #9
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,852

Rep: Reputation: 337Reputation: 337Reputation: 337Reputation: 337
finger command:
ARCHIVED: In Unix, what is the finger command?
https://kb.iu.edu/d/aasp
 
  


Reply


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
[SOLVED] The system time switches the time zone automatically but doesn't change the time RandomTroll Linux - Software 9 03-15-2013 12:28 PM
how to understand user time, sys time, wait time, idle time of CPU guixingyi Linux - Server 1 08-24-2010 10:10 AM
PAM time restrictions - changing Time.conf so it gets time from sql table noodlesoffire Linux - Newbie 1 04-04-2010 04:41 PM
System time vs Hardware time and Daylight Savings Time Toadman Linux - Networking 6 03-16-2007 07:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:49 PM.

Main Menu
Advertisement
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
Twitter: @linuxquestions
Open Source Consulting | Domain Registration