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:

  • Register used kernels.
  • Register the first boot time.
  • Count system startups.
  • Count good and bad shutdowns.
  • Calculate uptime and downtime percentage since first boot time.
  • Calculate the largest, shortest and average uptime and downtime.
  • Calculate the accumulated system uptime, downtime and total.
  • Print current uptime.
  • Print formatted table or list with most of the previous values stored.

 

Requirements:

  • Linux or FreeBSD OS.
  • Python 2.7 or 3.x installed but latest version is recommended.
  • 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

 

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

 

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

 

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

 

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 an 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 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.
Was this answer helpful? 0 Users Found This Useful (0 Votes)