- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to show historical and statistical running time of linux systems
The important part of the system administrators is to monitor and examine for a way long Linux system has been strolling. It is a just right concept to hold tracking up time of the Linux systems to optimise the system assets. This article describes Tuptime tool that can help System Administrators to know for how long a Linux machine has been up and running.
Tuptime tool is used for reporting the historical and statistical running time (uptime) of Linux systems, which tracks it between restarts.
Features
- Register the first boot time
- Tracks System startups
- Counts System shutdowns
- Calculates uptime and downtime
- Calculates largest, average, low uptime and downtime
- Print current uptime
Installing Tuptime Tool
To install Tuptime tool, the following pre-installed requirements should be fulfilled
- Python 2.7 or 3.X established but the latest variation is advocated.
- Python modules (sys, os, optparse, sqlite3, datetime, locale, platform, subprocess, time).
- Linux Operating system
To find the installed python on Linux, use the following command –
$ apt-cache search python | egrep "^python2.[0-9] " --color
The sample output should be like this –
python2.7 - Interactive high-level object-oriented language (version 2.7)
If your system does not have python installation, use the following command to install python-
$ sudo apt-get install python2.7
The sample output should be like this –
Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: python3.1-minimal Suggested packages: python3.1-doc python3.1-profiler The following NEW packages will be installed: python3.1 python3.1-minimal 0 upgraded, 2 newly installed, 0 to remove and 13 not upgraded. Need to get 5,444 kB of archives. After this operation, 19.9 MB of additional disk space will be used. Do you want to continue [Y/n]? y Get:1 http://debian.osuosl.org/debian/ squeeze/main python3.1-minimal amd64 3.1.3-1 [1,669 kB] Get:2 http://debian.osuosl.org/debian/ squeeze/main python3.1 amd64 3.1.3-1 [3,775 kB] Fetched 5,444 kB in 27s (201 kB/s) ...........................
To clone Tuptime repository from git, use the following command –
$ cd /tmp $ git clone https://github.com/rfrail3/tuptime.git $ ls $ cd tuptime $ ls
The sample output should be like this –
~$ cd /tmp /tmp$ git clone https://github.com/rfrail3/tuptime.git Cloning into 'tuptime'... remote: Counting objects: 2171, done. remote: Compressing objects: 100% (34/34), done. remote: Total 2171 (delta 21), reused 0 (delta 0), pack-reused 2137 Receiving objects: 100% (2171/2171), 749.33 KiB | 296.00 KiB/s, done. Resolving deltas: 100% (1056/1056), done. Checking connectivity... done. /tmp$ ls aptdaemon-A0RrYd sni-qt_vlc_15046-UFPBar unity_support_test.0 config-err-X4Efq6 sni-qt_vlc_15117-3D0jOa orbit-linux tuptime /tmp$ cd tuptime /tmp/tuptime$ ls CHANGELOG LICENSE scripts tuptime-install.sh debian README.md src tuptime-manual.txt
Install tuptime-install.sh as shown below –
# chmod +x tuptime-install.sh # ./tuptime-install.sh
The sample output should be like this –
Tuptime installation script Clonning repository... Cloning into '/tmp/tmp.P6j2npOJVU'... remote: Counting objects: 2171, done. remote: Compressing objects: 100% (34/34), done. remote: Total 2171 (delta 21), reused 0 (delta 0), pack-reused 2137 Receiving objects: 100% (2171/2171), 749.33 KiB | 318.00 KiB/s, done. Resolving deltas: 100% (1056/1056), done. Checking connectivity... done. Copying files... Creating tuptime user... Creating tuptime db Setting tuptime db ownership Executing tuptime with tuptime user for testing Copying init debian file... update-rc.d: warning: default start runlevel arguments (2 3 4 5) do not match tuptime Default-Start values (1 2 3 4 5) update-rc.d: warning: default stop runlevel arguments (0 1 6) do not match tuptime Default-Stop values (0 6) ....................................
Using Tuptime
To run Tuptime, use the following command-
# tuptime
The sample output should be like this –
System startups: 1 since 12:16:47 Tuesday 08 March 2016 System shutdowns: 0 ok - 0 bad System uptime: 100.0 % - 1 day, 2 hours, 18 minutes and 8 seconds System downtime: 0.0 % - 0 seconds System life: 1 day, 2 hours, 18 minutes and 8 seconds Largest uptime: 1 day, 2 hours, 18 minutes and 8 seconds from 12:16:47 Tuesday 08 March 2016 Shortest uptime: 1 day, 2 hours, 18 minutes and 8 seconds from 12:16:47 Tuesday 08 March 2016 Average uptime: 1 day, 2 hours, 18 minutes and 8 seconds Largest downtime: 0 seconds Shortest downtime: 0 seconds Average downtime: 0 seconds Current uptime: 1 day, 2 hours, 18 minutes and 8 seconds since 12:16:47 Tuesday 08 March 2016
To display output along date and time, use the following command –
# tuptime --date='%H:%M:%S %d-%m-%Y'
The sample output should be like this –
System startups: 1 since 12:16:47 08-03-2016 System shutdowns: 0 ok - 0 bad System uptime: 100.0 % - 1 day, 2 hours, 19 minutes and 41 seconds System downtime: 0.0 % - 0 seconds System life: 1 day, 2 hours, 19 minutes and 41 seconds Largest uptime: 1 day, 2 hours, 19 minutes and 41 seconds from 12:16:47 08-03-2016 Shortest uptime: 1 day, 2 hours, 19 minutes and 41 seconds from 12:16:47 08-03-2016 Average uptime: 1 day, 2 hours, 19 minutes and 41 seconds Largest downtime: 0 seconds Shortest downtime: 0 seconds Average downtime: 0 seconds Current uptime: 1 day, 2 hours, 19 minutes and 41 seconds since 12:16:47 08-03-2016
To print system file as a list, use the following command –
# tuptime --list
The sample output should be like this –
Startup: 1 at 12:16:47 Tuesday 08 March 2016 Uptime: 1 day, 2 hours, 21 minutes and 8 seconds
To create an alternative database file to store Tuptime log as shown below –
# tuptime --filedb /tmp/tuptime_testdb.db
The sample output should be like this –
System startups: 1 since 12:16:47 Tuesday 08 March 2016 System shutdowns: 0 ok - 0 bad System uptime: 100.0 % - 1 day, 2 hours, 22 minutes and 36 seconds System downtime: 0.0 % - 0 seconds System life: 1 day, 2 hours, 22 minutes and 36 seconds Largest uptime: 1 day, 2 hours, 22 minutes and 36 seconds from 12:16:47 Tuesday 08 March 2016 Shortest uptime: 1 day, 2 hours, 22 minutes and 36 seconds from 12:16:47 Tuesday 08 March 2016 Average uptime: 1 day, 2 hours, 22 minutes and 36 seconds Largest downtime: 0 seconds Shortest downtime: 0 seconds Average downtime: 0 seconds Current uptime: 1 day, 2 hours, 22 minutes and 36 seconds since 12:16:47 Tuesday 08 March 2016
To get information about power off at end state, use the following command –
# tuptime --end --table
The sample output should be like this –
No. Startup Date Uptime Shutdown Date End Downtime 1 12:16:47 Tuesday 08 March 2016 1 day, 2 hours, 23 minutes and 42 seconds
To print the kernel information, use the following command –
# tuptime --kernel
The sample output should be like this –
System startups: 1 since 12:16:47 Tuesday 08 March 2016 System shutdowns: 0 ok - 0 bad System uptime: 100.0 % - 1 day, 2 hours, 25 minutes and 4 seconds System downtime: 0.0 % - 0 seconds System life: 1 day, 2 hours, 25 minutes and 4 seconds System kernels: 1 Largest uptime: 1 day, 2 hours, 25 minutes and 4 seconds from 12:16:47 Tuesday 08 March 2016 ...with kernel: Linux-4.2.0-30-generic-x86_64-with-Ubuntu-14.04-trusty Shortest uptime: 1 day, 2 hours, 25 minutes and 4 seconds from 12:16:47 Tuesday 08 March 2016 ...with kernel: Linux-4.2.0-30-generic-x86_64-with-Ubuntu-14.04-trusty Average uptime: 1 day, 2 hours, 25 minutes and 4 seconds Largest downtime: 0 seconds ...with kernel: None Shortest downtime: 0 seconds ...with kernel: None Average downtime: 0 seconds Current uptime: 1 day, 2 hours, 25 minutes and 4 seconds since 12:16:47 Tuesday 08 March 2016 ...with kernel: Linux-4.2.0-30-generic-x86_64-with-Ubuntu-14.04-trusty
To get Tuptime help information, use the following command –
# tuptime --help
The standard output should be like this –
Usage: tuptime [options] Options: -h, --help show this help message and exit -c, --ckernel classify / order by kernel -d DATE_FORMAT, --date=DATE_FORMAT date format output -e, --end order by end state -f FILE, --filedb=FILE database file -g, --graceful register a gracefully shutdown -k, --kernel print kernel information -l, --list enumerate system life as list -o, --offtime order by offtime / downtime -r, --reverse reverse order -s, --seconds output time in seconds and epoch -t, --table enumerate system life as table -u, --uptime order by uptime -v, --verbose verbose output -V, --version show version -x, --silent update values into db without output
Congratulations! Now, you know “How to show Historical and Statistical Running Time of Linux Systems”. We’ll learn more about these types of commands in our next Linux post. Keep reading!
- Related Articles
- How to get the start time of a long running Linux Process?
- Signals and Systems: Time Variant and Time-Invariant Systems
- How to find and kill running processes in linux
- Netdata – A Real-Time Performance Monitoring Tool for Linux Systems
- Signals and Systems: Linear Time-Invariant Systems
- How to list running screen sessions on Linux?
- Signals and Systems – Properties of Linear Time-Invariant (LTI) Systems
- Signals and Systems – Time Scaling of Signals
- Init process on UNIX and Linux systems
- How to check Syntax of a Bash Script without running it in Linux?
- Shutdown and Reboot Linux Systems From the Terminal
- 25 Big Companies and Devices Running on GNU/Linux
- Signals and Systems – Time-Reversal Property of Fourier Transform
- Signals and Systems – Time-Shifting Property of Fourier Transform
- Signals and Systems – Time Integration Property of Fourier Transform
