Linux system administration involves many activities one of which is monitoring and checking for how long your system has been running. It is always a good idea to keep track of system uptime in order to optimize the use of system resources.
In this guide, we will explore a Linux tool called “tuptime” that can help system administrators determine how long a Linux machine has been up and running.
What is tuptime?
tuptime is a tool used to report the historical and statistical running time (uptime) of a Linux system, preserving this information between restarts. This tool functions similarly to the uptime command but offers more advanced output.
tuptime command line tool can:
- Register used kernels.
- Register for the first boot time.
- Count system startups.
- Count good and bad shutdowns.
- Calculate uptime and downtime percentage since the first boot time.
- Calculate the largest, shortest, and average uptime and downtime.
- Calculate the accumulated system uptime, downtime, and total.
- Print current uptime.
- Print a formatted table or list with most of the previous values stored.
Requirements
- Linux or FreeBSD OS.
- Python 2.7 or 3.x installed but the latest version is recommended.
- Python modules (sys, os, optparse, sqlite3, datetime, locale, platform, subprocess, time).
How to Install tuptime in Linux
To install tuptime on a Linux system, you can use the package manager specific to your distribution.
sudo apt install tuptime [On Debian, Ubuntu and Mint] sudo yum install tuptime [On RHEL/CentOS/Fedora and Rocky/AlmaLinux] sudo emerge -a sys-apps/tuptime [On Gentoo Linux] sudo apk add tuptime [On Alpine Linux] sudo pacman -S tuptime [On Arch Linux] sudo zypper install tuptime [On OpenSUSE] sudo pkg install tuptime [On FreeBSD]
Alternatively, you can use the following bash one-liner script to install tuptime on a Linux system using the curl command as shown.
bash < <(curl -Ls https://git.io/tuptime-install.sh)
For manual installation, you need to clone a Git repository called “tuptime” to your local machine.
git clone https://github.com/rfrail3/tuptime.git cp tuptime/src/tuptime /usr/bin/tuptime chmod ugo+x /usr/bin/tuptime tuptime
If you followed the above steps correctly, then it must be installed on your system at this point.
How Do I Use tuptime in Linux?
Next, we shall look at how to use the tuptime tool for certain system administration activities by running it with different options as a privileged user as shown.
1. When you run tuptime without any options, you get a display screen similar to the one below.
# tuptime
2. You can display output with date and time as follows.
# tuptime --date='%H:%M:%S %d-%m-%Y'
3. To print system life as a list, you can run this command below:
# tuptime --list
4. You can create an alternative database file as follows. The database will be created in a SQLite format.
# tuptime --filedb /tmp/tuptime_testdb.db
5. To order output information by end state of poweroff run this command.
# tuptime --end --table
Some other options used with the tuptime tool are as follows:
- To print the system kernel version in the output, use the
--kernel
option. - To register a graceful system shutdown, use the
--gracefully
option. It allows you to know whether the system shutdown was good or bad. - To display output after a given number of seconds and epoch, use the
--seconds
option. - You can also order output information by offtime or downtime by using the –offtime option. Use this option with
--time
or--list
. - To print detailed output information while running the command, use
--verbose
option. - You can view help information by using
--help
option and--version
to print the version of tuptime you are using.
Summary
In this article, we have explored how to use the tuptime command for system administration tasks. It is easy to use. If you have any questions about the guide or if there’s a point you don’t understand, feel free to post a comment or contribute additional information to enhance what has been shared.
Discover more from Hosting Mate
Subscribe to get the latest posts sent to your email.