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 https://xkcd.com/705/][1]][1]
One can tell how long the Linux system has been running using the uptime command or [w command][2] or top command. I can get [a report of the historical and statistical running time of the system][3], 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][3] 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][4]/[apt-get command][5]:
`$ 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:
libuptimed0
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.
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][9]][9]
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
```
## Conclusion
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][10] 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.][11]][11]
[4]:https://www.cyberciti.biz//www.cyberciti.biz/faq/ubuntu-lts-debian-linux-apt-command-examples/ (See Linux/Unix apt command examples for more info)
[5]:https://www.cyberciti.biz//www.cyberciti.biz/tips/linux-debian-package-management-cheat-sheet.html (See Linux/Unix apt-get command examples for more info)