tuptime – Shows Historical and Statistical Running Time of Linux Systems

System Administration involves many activities one of which is monitoring and checking for how long your Linux 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.

Find Linux Uptime, Shutdown and Reboot Time
tuptime – Shows Historical and Statistical Running Time of Linux

In this guide, we shall look at a Linux tool called tuptime that can help System Administrators to know for how long a Linux machine has been up and running.

What is tuptime?

tuptime is a tool used for reporting the historical and statistical running time (uptime) of a Linux system, which keeps it between restarts. This tool works more less like the uptime command but though it provides a more advanced output.

This command line tool can:

  1. Register used kernels.
  2. Register the first boot time.
  3. Count system startups.
  4. Count good and bad shutdowns.
  5. Calculate uptime and downtime percentage since first boot time.
  6. Calculate the largest, shortest and average uptime and downtime.
  7. Calculate the accumulated system uptime, downtime and total.
  8. Print current uptime.
  9. Print formatted table or list with most of the previous values stored.

Requirements

  1. Linux or FreeBSD OS.
  2. Python 2.7 or 3.x installed but latest version is recommended.
  3. Python modules (sys, os, optparse, sqlite3, datetime, locale, platform, subprocess, time).

How to Install tuptime in Linux

First you need to clone the repository by running the command below:

$ git clone https://github.com/rfrail3/tuptime.git
Clone tuptime Tool
Clone tuptime Tool

Then move into the latest directory inside the tuptime directory. Next, copy tuptime script inside the latest directory to /usr/bin and set executable permission as shown.

$ cd tuptime/latest 
$ sudo cp tuptime /usr/bin/tuptime
$ sudo chmod ugo+x /usr/bin/tuptime
Configure tuptime
Configure tuptime

Now, copy the cron file tuptime/latest/cron.d/tuptime to /etc/cron.d/tuptime and set executable permission as follows.

$ sudo cp tuptime/latest/cron.d/tuptime /etc/cron.d/tuptime
$ sudo chmod 644 /etc/cron.d/tuptime
Configure tuptime Cron
Configure tuptime Cron

If you followed above these steps correctly, then it must be installed on your system at this point.

How do I use tuptime?

Next we shall look at how to use this 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
tuptime in action
tuptime in action

2. You can display output with date and time as follows.

# tuptime --date='%H:%M:%S %d-%m-%Y'
tuptime date and time
tuptime date and time

3. To print system life as a list, you can run this command below:

# tuptime --list
Check Linux Uptime
Check Linux Uptime

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
tuptime Database
tuptime Database

5. To order output information by end state of poweroff run this command.

# tuptime --end --table
Check Linux Last Shutdown
Check Linux Last Shutdown

Some other options used with the tuptime tool as follows:

  1. To print the system kernel version in the output, use the --kernel option.
  2. To register a gracefully system shutdown, use the --gracefully option. It allows you to know whether the system shutdown was good or bad.
  3. To display output after a given number of seconds and epoch, use the --seconds option.
  4. You can also order output information by offtime or downtime by using the –offtime option. Use this option with --time or --list.
  5. To print detailed output information while running the command, use --verbose option.
  6. 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 looked at ways of using tuptime command for System Administration activities. This command is simple to use and if you do not understand any point in the guide, you can post a comment or add more information what I have put together. Remember to stay connected to Tecmint.

References: tuptime home page

If you read this far, tweet to the author to show them you care. Tweet a thanks
Aaron Kili
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.