Measure system runtime with tuptime Stopwatch
Measure system runtime with tuptime Stopwatch
How long has the Linux server been running without rebooting? And how often has the system rebooted without you noticing? These questions and more are answered by the tuptime tool.
If a Linux system has been running for a long time, this is definitely proof of its stability, but – depending on the distribution – some updates might be waiting to install. Conversely, if the system reboots very frequently, there may be a configuration error – or maybe a hardware component is slowly deteriorating. On a workstation computer, such restarts are quickly noticed, but not necessarily on a remote server that is running quietly and well away from the action.
How long a system has been running continuously can be determined at the command line by a call to uptime
. But you might also want to try tuptime [1], a similar tool whose name is based on a contraction of "total uptime." It outputs far more information, including valuable information in the form of the number of reboots and the kernel version used.
Installation
While uptime
is available on almost every system, you need to install tuptime separately. Some distributions already have the tool in their repositories, such as Debian and Ubuntu. Arch Linux users will find tuptime in the AUR and CentOS users in the EPEL repository. On any Linux system, you can install the tool with the following:
$ curl -Ls https://git.io/tuptime-install.sh | sudo bash
Tuptime itself consists of a Python script and requires Python 3 with the modules sys
, os
, optparse
, sqlite3
, locale
, platform
, datetime
, and logging
. These modules should be preinstalled on most distributions. For more information about installation, see the box "In the Background."
In the Background
The system calls tuptime
briefly during the boot and shutdown processes. In each case, the tool notes the system time. It is from the timestamps collected in this way that tuptime ultimately calculates the total runtime and all other values.
To make tuptime start automatically at boot and shutdown time, tuptime-install.sh
sets up some startup scripts. For example, it sets up a corresponding service unit on a system with systemd. Besides systemd, the installation script also supports SysVinit and OpenRC. When using the installation script, tuptime also always runs under its own user account, named _tuptime
.
If at some point the power should suddenly fail, tuptime would not notice anything. As a consequence, the timestamp for the shutdown would be missing, and this would prevent the tool from calculating the correct total runtime. For this reason, the installation script additionally sets up a cron job, which in turn ensures that tuptime is launched at regular intervals. All timestamps noted by tuptime end up in a small SQLite database, which is located below /var/lib/tuptime/tuptime.db
by default.
Time Measurement
After setting up the program, query the current status via tuptime
in the terminal. The tool already provides some basic information (Figure 1): At the very top; it shows the number of system starts. Next to it you can see the time and date since the software started counting the starts. Tuptime doesn't capture events before this date. To get a complete picture, set up the program as soon as possible after system installation.

Next, tuptime tells you how often the system has been shut down (System shutdowns). Pay special attention to the number of uncontrolled shutdowns labeled bad. If this figure increases rapidly, there is a major problem, for example an unstable power supply. System life indicates how long tuptime has been monitoring the system. If you installed tuptime directly after the installation of the distribution, this value corresponds to the time since the first boot.
This is followed by the total system uptime (System uptime) and the total time the computer was powered off (System downtime). If the percentage of downtime exceeds 50 percent, the computer was off longer than in operation. How long the system was in operation on average is indicated by the value following Average uptime. Similarly, Average downtime indicates how long the computer was switched off on average. The final value is the time since the last system start (Current uptime).
Display Options
The tuptime -l
command returns a list with all startup operations. In the list, you can see in detail when the system was in operation and for how long. If the list seems too confusing, tuptime -t
converts the data to tabular form like shown in Figure 2. The additional -r
parameter reverses the order; the last system start appears at the top.

If you still feel overwhelmed by the volume of information, the display can be limited to a certain period of time. For example, if you want to know when and for how long the system was active between July 27 and July 28, 2020, just call tuptime
with the command:
$ tuptime --tsince=$(date --date="2020-07-27" +%s) --tuntil=$(date --date="2020-07-28" +%s)
The --tsince
and --tuntil
parameters each expect a timestamp that is calculated by date. Tuptime also outputs these timestamps with the -s
parameter.
Alternatively, you can limit the output to very specific startup operations. For example, if you are interested in how long the system ran from the very first to the fifth logged startup, use the following:
$ tuptime --since 1 --until 5
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Direct Download
Read full article as PDF:
Price $2.95
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Find SysAdmin Jobs
News
-
Kubuntu Focus Announces XE Gen 2 Linux Laptop
Another Kubuntu-based laptop has arrived to be your next ultra-portable powerhouse with a Linux heart.
-
MNT Seeks Financial Backing for New Seven-Inch Linux Laptop
MNT Pocket Reform is a tiny laptop that is modular, upgradable, recyclable, reusable, and ships with Debian Linux.
-
Ubuntu Flatpak Remix Adds Flatpak Support Preinstalled
If you're looking for a version of Ubuntu that includes Flatpak support out of the box, there's one clear option.
-
Gnome 44 Release Candidate Now Available
The Gnome 44 release candidate has officially arrived and adds a few changes into the mix.
-
Flathub Vying to Become the Standard Linux App Store
If the Flathub team has any say in the matter, their product will become the default tool for installing Linux apps in 2023.
-
Debian 12 to Ship with KDE Plasma 5.27
The Debian development team has shifted to the latest version of KDE for their testing branch.
-
Planet Computers Launches ARM-based Linux Desktop PCs
The firm that originally released a line of mobile keyboards has taken a different direction and has developed a new line of out-of-the-box mini Linux desktop computers.
-
Ubuntu No Longer Shipping with Flatpak
In a move that probably won’t come as a shock to many, Ubuntu and all of its official spins will no longer ship with Flatpak installed.
-
openSUSE Leap 15.5 Beta Now Available
The final version of the Leap 15 series of openSUSE is available for beta testing and offers only new software versions.
-
Linux Kernel 6.2 Released with New Hardware Support
Find out what's new in the most recent release from Linus Torvalds and the Linux kernel team.