Check Historical and Statistical Uptime of Linux

Linux TLDR
Last Updated:
Reading time: 3 minutes

As a system administrator, you may want to look for various information on your workstation or server system, such as how long the system has been running.

This way, you can keep track of the system resources and optimize based on your usage. Unfortunately, the uptime command used to get this information only returns information for the current session.

Surprisingly, you have an external tuptime command-line tool that can offer you historical and statistical uptime information for your Linux system.

Tutorial Details

DescriptionFind Historical and Statistical Uptime Information for Linux
Difficulty LevelLow
Root or Sudo PrivilegesNo
OS CompatibilityUbuntu, Manjaro, Fedora, etc.
Prerequisitestuptime
Internet RequiredYes

What is the Linux Tuptime Tool?

The tuptime is an external command-line utility in Linux used to check the report of historical and statistical running time of a Linux system.

The functionality is identical to uptime, except it offers you historical and statistical uptime data with more advanced output.

Tuptime Features

The following is a list of the features offered by this tool:

  • Count system startups.
  • Print the current uptime.
  • Register the first boot time.
  • Register used kernels and boot IDs.
  • Count both intentional and unintentional shutdowns.
  • Calculate the uptime and downtime percentages since the first boot.
  • Calculate the average, shortest, and largest uptime and downtime.
  • Calculate the accumulated system uptime (running and sleeping), downtime, and total.
  • Print a formatted table or list with the system history.
  • Output in CSV format.

How to Install Tuptime Tool in Linux

As previously stated, this is an external command-line tool that must be installed separately on your Linux system using the methods mentioned in this section.

The easiest way to install this command-line tool is to use the system’s default package manager to run any one of the following commands:

$ sudo apt install tuptime                                                                           #On Debian and Ubuntu
$ sudo dnf install tuptime                                                                           #On Red Hat and Fedora

If you are using a different system that does not include this tool in its repository, then you have to follow the next method, where you have to run a shell script that will automatically clone and copy the binary into your bin directory and configure the cron job for you.

πŸ“
While following the next method, make sure you have the Python 3.X package installed on your Linux system.
$ bash < <(curl -Ls https://git.io/tuptime-install.sh)

If you prefer manual installation, then you can follow this guide.

How to Use the Tuptime Tool in Linux

The tuptime command takes one argument as an option (optional).

$ tuptime [OPTION]

Most of the time, you will run this command without specifying any options, and as you do, you will be presented with the following screen.

Output of the tuptime command without option

From the above picture, you can clearly see the historical and statistical uptime information for my Linux system.

It includes the number of system startups since the tuptime was installed, the number of good/bad shutdowns, the current system uptime, the average uptime/downtime, etc.

Change the Date and Time Format

Using the β€œ-d” flag, you can specify your own custom date and time format, as one shown in the following example.

$ tuptime -d='%H:%M:%S %d-%m-%Y'

Output:

Custom date and time format

Display the System Kernel Version and Boot ID

The β€œ-k” flag will display the kernel version, and the β€œ-b” flag will display the boot ID of the system.

$ tuptime -kb

Output:

Show the kernel version and boot ID

Display the System Life in List

The β€œ-l” flag will display the system life (or each session uptime information) in a list.

$ tuptime -l

Output:

Enumerate system life as list

Display the System Life in Table

The β€œ-t” flag can be used in the same way as the previous command to show the system life in a table.

$ tuptime -t

Output:

Enumerate system life as table

Display Detailed System Life Information

The β€œ-v” flag will enable the verbose mode, which basically gives you the complete information for various parameters that require a separate flag.

$ tuptime -v

Output:

Verbose mode

Save the Output in a CSV File

The β€œ-c” flag will print the output in CSV format, which can be saved in a β€œ.csv” file using the β€œ>” redirection symbol.

$ tuptime -c > tuptime.csv
$ cat tuptime.csv 

Output:

Print the output in CSV format

Specify a Custom Database Path

To change the default database to a different one, use the β€œ--filedb” option with the path to the new database as an argument.

$ tuptime --filedb /tmp/tuptime_db.db

Output:

Custom database

Conclusion

I hope you will find this article useful and that you have learned another amazing sysadmin tool in your Linux journey.

However, if you have any questions or queries related to this topic, feel free to ask them in the comment section.

Till then, peace!

Join The Conversation

Users are always welcome to leave comments about the articles, whether they are questions, comments, constructive criticism, old information, or notices of typos. Please keep in mind that all comments are moderated according to our comment policy.

3 thoughts on β€œCheck Historical and Statistical Uptime of Linux”