LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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 03-17-2018, 07:21 PM   #1
Michael Piziak
Member
 
Registered: Feb 2015
Distribution: Ubuntu 20.04 lts
Posts: 598

Rep: Reputation: 43
How to find out hours on a computer?


Is there a linux terminal command or program (preferbably in the Ubuntu Software center, to tell how many hours of usage are on a computer?
 
Old 03-17-2018, 07:47 PM   #2
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Code:
uptime -p
 
Old 03-17-2018, 07:49 PM   #3
Soadyheid
Senior Member
 
Registered: Aug 2010
Location: Near Edinburgh, Scotland
Distribution: Cinnamon Mint 20.1 (Laptop) and 20.2 (Desktop)
Posts: 1,672

Rep: Reputation: 486Reputation: 486Reputation: 486Reputation: 486Reputation: 486
To tell how long since the last reboot:

Code:
$ uptime
My system for today (I power it down each evening.)
Code:
$ uptime
 00:48:46 up 13:23,  1 user,  load average: 0.31, 0.39, 0.39

Play Bonny!

 
Old 03-17-2018, 08:06 PM   #4
Michael Piziak
Member
 
Registered: Feb 2015
Distribution: Ubuntu 20.04 lts
Posts: 598

Original Poster
Rep: Reputation: 43
Are these commands only for the current uptime usage. I would like to know the total usage time the computer has on it since it was manufactured.
 
Old 03-17-2018, 08:10 PM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
It depends on what you mean by "hours of usage". As posted uptime will tell you how long the computer has been running since last power on but not total history of run time hours.

There is a utility tuptime that can track total hours which I think is in the ubuntu repository but it can not go back to the "beginning" You can look at the SMART data of the drive to see run time hours and that would be equal to the total hours of usage assuming the drive was new when the system was first built.
 
Old 03-17-2018, 09:04 PM   #6
ferrari
LQ Guru
 
Registered: Sep 2003
Location: Auckland, NZ
Distribution: openSUSE Leap
Posts: 5,803

Rep: Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140Reputation: 1140
Quote:
You can look at the SMART data of the drive to see run time hours and that would be equal to the total hours of usage assuming the drive was new when the system was first built.
That's a good idea for total "engine hours".
 
Old 03-17-2018, 09:21 PM   #7
Michael Piziak
Member
 
Registered: Feb 2015
Distribution: Ubuntu 20.04 lts
Posts: 598

Original Poster
Rep: Reputation: 43
The amount of hours on the hard drive would be fine.

Anyone know the name of the program in "Ubuntu Software" will do this?
 
Old 03-17-2018, 09:28 PM   #8
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
There is smartctl command line tool
ie with /dev/sda, as root:
Code:
smartctl -a /dev/sda | awk '/Power_On_Hours/{print $NF " hours"}'
 
Old 03-17-2018, 09:38 PM   #9
Michael Piziak
Member
 
Registered: Feb 2015
Distribution: Ubuntu 20.04 lts
Posts: 598

Original Poster
Rep: Reputation: 43
Quote:
Originally Posted by keefaz View Post
There is smartctl command line tool
ie with /dev/sda, as root:
Code:
smartctl -a /dev/sda | awk '/Power_On_Hours/{print $NF " hours"}'
Thank you
 
Old 03-18-2018, 11:37 AM   #10
Soadyheid
Senior Member
 
Registered: Aug 2010
Location: Near Edinburgh, Scotland
Distribution: Cinnamon Mint 20.1 (Laptop) and 20.2 (Desktop)
Posts: 1,672

Rep: Reputation: 486Reputation: 486Reputation: 486Reputation: 486Reputation: 486
NOTE: You need to have smartmontools installed for the above command to work. You'll get an answer to the disk runtime in hours, if you've more than one disk you can check each separately.

The package gsmartcontrol will also give you a graphic front end if that's your thing, it'll install smartmontools as a dependency.

Play Bonny!

 
Old 03-19-2018, 10:50 AM   #11
Michael Piziak
Member
 
Registered: Feb 2015
Distribution: Ubuntu 20.04 lts
Posts: 598

Original Poster
Rep: Reputation: 43
Quote:
Originally Posted by Soadyheid View Post
NOTE: You need to have smartmontools installed for the above command to work. You'll get an answer to the disk runtime in hours, if you've more than one disk you can check each separately.

The package gsmartcontrol will also give you a graphic front end if that's your thing, it'll install smartmontools as a dependency.

Play Bonny!

I installed smartmontools and now when I enter smartctl -a /dev/sda | awk '/Power_On_Hours/{print $NF " hours"}' into terminal, it doesn't give me any report. ???
Attached Thumbnails
Click image for larger version

Name:	Screenshot from 2018-03-19 12-01-28.png
Views:	8
Size:	250.9 KB
ID:	27222  

Last edited by Michael Piziak; 03-19-2018 at 11:03 AM. Reason: Adding screenshot
 
Old 03-19-2018, 11:15 AM   #12
Soadyheid
Senior Member
 
Registered: Aug 2010
Location: Near Edinburgh, Scotland
Distribution: Cinnamon Mint 20.1 (Laptop) and 20.2 (Desktop)
Posts: 1,672

Rep: Reputation: 486Reputation: 486Reputation: 486Reputation: 486Reputation: 486
Code:
Soadyheid ~ $ smartctl -a /dev/sda | awk '/Power_On_Hours/{print $NF " hours"}'
Soadyheid ~ $ sudo smartctl -a /dev/sda | awk '/Power_On_Hours/{print $NF " hours"}'
[sudo] password for Soadyheid: 
31607 hours
Soadyheid ~ $
Yup! I get nothing as well, try running it with sudo as per my second attempt above.

Play Bonny!

 
Old 03-19-2018, 11:19 AM   #13
Michael Piziak
Member
 
Registered: Feb 2015
Distribution: Ubuntu 20.04 lts
Posts: 598

Original Poster
Rep: Reputation: 43
Quote:
Originally Posted by Soadyheid View Post
Code:
Soadyheid ~ $ smartctl -a /dev/sda | awk '/Power_On_Hours/{print $NF " hours"}'
Soadyheid ~ $ sudo smartctl -a /dev/sda | awk '/Power_On_Hours/{print $NF " hours"}'
[sudo] password for Soadyheid: 
31607 hours
Soadyheid ~ $
Yup! I get nothing as well, try running it with sudo as per my second attempt above.

Play Bonny!


Thanks!
sudo smartctl -a /dev/sda | awk '/Power_On_Hours/{print $NF " hours"}' WORKED
 
  


Reply



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] How can I tell how many hours a computer has been running in its life? Brant Linux - Hardware 9 03-06-2023 03:42 AM
Computer become hang when left idle for few hours sauravrukd Linux - Software 2 11-23-2011 07:04 AM
My computer is taking more than 4 hours to install linux sahusandi Linux - Software 5 09-14-2007 11:51 PM
How many hours a day on your computer? DanTaylor General 24 04-05-2006 08:45 PM
mysql down...can't find a fix after several hours :( I_AM Linux - General 1 03-02-2005 08:34 PM

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

All times are GMT -5. The time now is 06:30 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