How to record statistics about a Linux machine’s uptime

Linux/Unix sysadmins have a weird obsession with server uptime. There is a xkcd comic devoted to this subject where a good sysadmin is an unstoppable force that it stands between the forces of darkness and your cat blog’s servers.

Fig.01: Devotion to Duty

Fig.01: Devotion to Duty

One can tell how long the Linux system has been running using the uptime command or w command or top command. I can get a report of the historical and statistical running time of the system, keeping it between restarts using tuptime tool.

Like uptime command but with the more impressive output. Recently I discovered another tool called uptimed that records statistics about a machine’s uptime. Let us see how to get uptime record statistics using uptimed and uprecords on Linux operating system.

Finding uptime is pretty easy, just type the following on your Linux based system:
$ uptime -p
up 2 weeks, 4 days, 7 hours, 28 minutes

To keep historical stats about uptime use either tuptime or uptimed tool.

uptimed installation

The simplest way to install uptimed locally is through your package managers such as apt/apt-get/yum and friends as per your Linux distro.

Install uptimed on a Debian/Ubuntu Linux

Type the following apt command/apt-get command:
$ sudo apt-get install uptimed
Sample outputs:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
The following NEW packages will be installed:
  libuptimed0 uptimed
0 upgraded, 2 newly installed, 0 to remove and 3 not upgraded.
Need to get 40.7 kB of archives.
After this operation, 228 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 xenial/universe amd64 libuptimed0 amd64 1:0.3.17-4 [9,050 B]
Get:2 xenial/universe amd64 uptimed amd64 1:0.3.17-4 [31.6 kB]
Fetched 40.7 kB in 0s (2,738 kB/s)  
Preconfiguring packages ...
Selecting previously unselected package libuptimed0.
(Reading database ... 39163 files and directories currently installed.)
Preparing to unpack .../libuptimed0_1%3a0.3.17-4_amd64.deb ...
Unpacking libuptimed0 (1:0.3.17-4) ...
Selecting previously unselected package uptimed.
Preparing to unpack .../uptimed_1%3a0.3.17-4_amd64.deb ...
Unpacking uptimed (1:0.3.17-4) ...
Processing triggers for systemd (229-4ubuntu21) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up libuptimed0 (1:0.3.17-4) ...
Setting up uptimed (1:0.3.17-4) ...
Processing triggers for libc-bin (2.23-0ubuntu9) ...
Processing triggers for systemd (229-4ubuntu21) ...
Processing triggers for ureadahead (0.100.0-19) ...

Install uptimed on a CentOS/RHEL/Fedora/Oracle/Scientific Linux

First enable EPEL repo on a CentOS/RHEL:
$ sudo yum -y install epel-release
Next, type the following yum command:
$ sudo yum install uptimed
Sample outputs:

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base:
 * epel:
 * extras:
 * updates:
Resolving Dependencies
--> Running transaction check
---> Package uptimed.x86_64 0:0.4.0-6.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
 Package           Arch             Version               Repository      Size
 uptimed           x86_64           0.4.0-6.el7           epel            47 k
Transaction Summary
Install  1 Package
Total download size: 47 k
Installed size: 98 k
Is this ok [y/d/N]: y
Downloading packages:
uptimed-0.4.0-6.el7.x86_64.rpm                            |  47 kB   00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : uptimed-0.4.0-6.el7.x86_64                                  1/1 
  Verifying  : uptimed-0.4.0-6.el7.x86_64                                  1/1 
  uptimed.x86_64 0:0.4.0-6.el7                                                 

If you are using a Fedora Linux, run the following dnf command:
$ sudo dnf install uptimed

Install uptimed on an Arch Linux

Type the following pacman command:
$ sudo pacman -S uptimed

Install uptimed on a Gentoo Linux

Type the following emerge command:
$ sudo emerge --ask uptimed

How to configure uptimed

Edit the file /etc/uptimed.conf using a text editor such as vim command:
$ sudo vim /etc/uptimed.conf
At least set an email address to mail milestones/records to. Assumes sendmail compatible MTA installed as /usr/lib/sendmail.
Save and close the file.

How do I enable uptimed service at boot time?

Enable uptimed service using the systemctl command:
$ sudo systemctl enable uptimed

How do I start/stop/restart or view status of uptimed service?

$ sudo systemctl start uptimed ## start it ##
$ sudo systemctl stop uptimed ## stop it ##
$ sudo systemctl restart uptimed ## restart it ##
$ sudo systemctl status uptimed ## view status ##

Sample outputs:

● uptimed.service - uptime record daemon
   Loaded: loaded (/lib/systemd/system/uptimed.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2017-11-09 17:49:14 UTC; 18min ago
 Main PID: 11137 (uptimed)
   CGroup: /system.slice/uptimed.service
           └─11137 /usr/sbin/uptimed -f
Nov 09 17:49:14 gfs04 systemd[1]: Started uptime record daemon.

How to see uptime record

Simply type the following command to see statistics from the uptimed(8) program:
$ uprecords
Sample outputs:

Fig.02: uprecords in action

uprecords has a few more option:
$ uprecords -?
Sample outputs:
usage: uprecords [OPTION]...
  -?             this help
  -a             do not print ansi codes
  -b             sort by boottime
  -B             reverse sort by boottime
  -k             sort by sysinfo
  -K             reverse sort by sysinfo
  -d             print downtime seen before every uptimes instead of system
  -c             do not show current entry if not in top entries
  -f             run continously in a loop
  -s             do not print extra statistics
  -w             wide output (more than 80 cols per line)
  -i INTERVAL    use INTERVAL seconds for loop instead of 5, implies -f
  -m COUNT       show a maximum of top COUNT entries instead of 10
  -M             show next milestone
  -v             version information


This is an excellent little tool to show your server uptime records to prove your uptime and business continuity. On a related note, you should get the official XKCD sysadmin t-shirt as comic was made into a shirt, which includes a new illustration on the back.

Fig.03: Sysadmin XKCD shirt features the original comic on the front and a new illustration on the back.

This entry is 2 of 2 in the Linux uptime series. Keep reading the rest of the series:
  1. Report the historical and statistical running time of Linux system
  2. How to records statistics about a Linux machine's uptime

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 3 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
3 comments… add one
  • Aram Iskenderian Nov 13, 2017 @ 10:36

    Nice find.
    The title should be corrected from:
    “How to records statistics about a Linux machine’s uptime”
    “How to record statistics about a Linux machine’s uptime”

    Not a big deal though. Thanks.

  • Jalal Dec 12, 2017 @ 4:21

    Thanks a lot,
    Very useful material.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum