LinuxQuestions.org
Review your favorite Linux distribution.
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, 03: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 03:16 AM.
 
Old 05-08-2017, 04:25 AM   #2
mrmazda
LQ Guru
 
Registered: Aug 2016
Location: USA
Distribution: openSUSE 24/7; Debian, Knoppix, Mageia, Fedora, others
Posts: 5,511
Blog Entries: 1

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
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, 04:56 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,123

Rep: Reputation: 7141Reputation: 7141Reputation: 7141Reputation: 7141Reputation: 7141Reputation: 7141Reputation: 7141Reputation: 7141Reputation: 7141Reputation: 7141Reputation: 7141
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, 07: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 08:32 AM.
 
Old 05-08-2017, 07:41 AM   #5
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,843
Blog Entries: 13

Rep: Reputation: 4894Reputation: 4894Reputation: 4894Reputation: 4894Reputation: 4894Reputation: 4894Reputation: 4894Reputation: 4894Reputation: 4894Reputation: 4894Reputation: 4894
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, 10:21 AM   #6
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,424
Blog Entries: 4

Rep: Reputation: 3838Reputation: 3838Reputation: 3838Reputation: 3838Reputation: 3838Reputation: 3838Reputation: 3838Reputation: 3838Reputation: 3838Reputation: 3838Reputation: 3838
man who
 
Old 05-08-2017, 12:58 PM   #7
jamison20000e
Senior Member
 
Registered: Nov 2005
Location: ...uncanny valley... infinity\1975; (randomly born:) Milwaukee, WI, US( + travel,) Earth&Mars (I wish,) END BORDER$!◣◢┌∩┐ Fe26-E,e...
Distribution: any GPL that work on freest-HW; has been KDE, CLI, Novena-SBC but open.. http://goo.gl/NqgqJx &c ;-)
Posts: 4,888
Blog Entries: 2

Rep: Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567Reputation: 1567
Talking

Click image for larger version

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

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

Rep: Reputation: 436Reputation: 436Reputation: 436Reputation: 436Reputation: 436
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 01:28 PM
how to understand user time, sys time, wait time, idle time of CPU guixingyi Linux - Server 1 08-24-2010 11:10 AM
PAM time restrictions - changing Time.conf so it gets time from sql table noodlesoffire Linux - Newbie 1 04-04-2010 05:41 PM
System time vs Hardware time and Daylight Savings Time Toadman Linux - Networking 6 03-16-2007 08:14 PM

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

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

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