Monday, May 6, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 357  / 2 Years ago, fri, may 27, 2022, 1:55:23

Is there a command or script that can tell me for how long the server has been up since installation?

(either by checking system installation date (+ removing shutdown-time) or by checking main disk uptime)


something similar to what "crystal disk info" can do for windows


Thanks


More From » 18.04

 Answers
7

I do not believe we have something like that.


This will show when a system was installed:


$ sudo tune2fs -l /dev/sda1 | grep 'Filesystem created:'
Filesystem created: Sat Jun 14 18:29:43 2014

Replace /dev/sda1 with the device name you need (1st column of df / will show you what you want). But I do not believe I ever saw a command to show how long a system has been turned on or off.


uptime

will only show how long the current uptime is.


This will list the last 1000 reboots/shutdowns:


last -1000 reboot shutdown

But that lacks the moment the system was turned on after a shutdown.


edit:


How about an approach like this (it will list the hours a disk has been active):


 smartctl --attributes /dev/sda | grep Power_On_Hours

Replace /dev/sda with your device name and install it with sudo apt smartmontools if not available yet. Not totally perfect as it assumes you started using the disk when the system was installed.


[#2645] Saturday, May 28, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
whoppinolo

Total Points: 93
Total Questions: 113
Total Answers: 107

Location: Cyprus
Member since Mon, Oct 24, 2022
2 Years ago
whoppinolo questions
Tue, Feb 14, 23, 08:30, 1 Year ago
Wed, Sep 28, 22, 06:56, 2 Years ago
Tue, Oct 12, 21, 09:33, 3 Years ago
Mon, Oct 4, 21, 19:35, 3 Years ago
;