Linux server running time

How to Check Uptime of Your Linux Server

Stop wondering how long your system has been running. Just check its uptime with uptime command.

The uptime command in Linux is used for finding how long the Linux system has been up and running.

It is one of the simplest Linux commands. Just run it without any options:

This will show you a single line of output that shows the current time, the uptime (in days and hours), the number of users currently logged on to the system, and the load average.

Here’s a sample output of the uptime command:

[email protected]:~$ uptime 16:13:00 up 2 days, 8:18, 1 user, load average: 1.19, 1.54, 1.51

You can probably identify the uptime but let me explain all the elements of this output.

  1. 16:13:00: This is the current time on the system.
  2. up 2 days, 8:18: This means the Linux system has been running for the last 2 days, 8 hours and 18 minutes.
  3. 1 user: This is the number of users currently logged into the Linux system.
  4. load average: 1.19, 1.54, 1.51: This gives the average CPU load for the past 1, 5 and 15 minutes. 1.54 means that 154% of the CPU consumption (if it’s a 4-core CPU, it means 1.54 out of 4 cores were in use).

The uptime command gets the boot related information from the /proc files like most other commands. It uses the /var/run/utmp file to get the information on the logged-in users.

It’s not that uptime doesn’t have any option at all. There are only a few but could be useful in some cases.

Using uptime command with options

If you think the output of the uptime command is too cluttered, you can use the pretty print option -p :

It will show just the uptime information, that too in words, which is more understandable.

[email protected]:~$ uptime -p up 2 days, 8 hours, 47 minutes

If you want to know since when the Linux server is running, you can use the option -s :

It will give the exact timestamp when your system booted the last time:

Читайте также:  Linux kernel release version

Uptime command with options

There is also option -V that shows command version and -h for showing the help page.

The default output of the uptime command shows the same information you get in the first line of the w command.

Bonus Tip: Keep a record of your uptimes

The uptime command only shows how long your system has been running.

There is a handy utility called uprecords that provides the record of your uptimes.

No kidding! It shows the best (longest) uptimes of your Linux system in a tabular format with additional information about the boot time, duration and Linux kernel version.

Output of uprecords command

This uprecords command is not installed by default. It is available in the package called uptimed and you have to install it on your system.

On Debian/Ubuntu, you can use:

It’s basically a daemon that tracks a system’s highest uptimes via boot IDs, using the system boot time to keep sessions apart from each other.

Once uptimed is installed, you can use the uprecords command to show the uptime records:

Keep in mind that you won’t get historical uptime records straightaway. It starts recording since the time uptimed daemon is installed.

Now that you know how to check Linux server uptime, watch and listen to this fantastic song called Uptime Funk (parody of Uptown Funk):

So, when was the last time you restarted your Linux server.

Источник

Linux Uptime Command With Usage Examples

The Linux Operating System is filled with several commands which any aspiring Linux expert or power user e.g. system admin must have a good grasp of. One of such commands is uptime and today, I’ll briefly discuss its purpose and syntax.

Uptime is a command that returns information about how long your system has been running together with the current time, number of users with running sessions, and the system load averages for the past 1, 5, and 15 minutes. It can also filter the information displayed at once depending on your specified options.

uptime uses a simple syntax:

Using Uptime

You can run the uptime command without any options like so:

It will display an output similar to:

09:10:18 up 106 days, 32 min, 2 users, load average: 0.22, 0.41, 0.32

In order of appearance, the command displays the current time as the 1st entry, up means that the system is running and it is displayed next to the total time for which the system has been running, the user count (number of logged on users), and lastly, the system load averages.

Читайте также:  Double commander linux mint

What are system load averages? It is the average number of processes that are in a runnable or uninterruptable state. A process is in a runnable state when it is using the CPU or waiting to use the CPU; while a process is in an uninterruptable state when it is waiting for I/O access like waiting for a disk.

To know more about uptime, check out our article: Understand Linux Load Averages and Monitor Performance of Linux

Now let’s see some useful uptime command usage with examples.

Check Linux Server Uptime

You can filter uptime’s result to show only the running time of the system with the command:

# uptime -p up 58 minutes 

Check Linux Server Starting Time

Using option -s will display the date/time since when the system has been running.

# uptime -s 2019-05-31 11:49:17 

Uptime Version & Help

As it is with most command line apps, you can display uptime’s version information and quick help page with the following command.

# uptime -h Usage: uptime [options] Options: -p, --pretty show uptime in pretty format -h, --help display this help and exit -s, --since system up since -V, --version output version information and exit For more details see uptime(1).

Having gotten to this point in the article, you can now use uptime for your daily runs and you’ll determine its level of usefulness to you. If you have any doubts, here’s its man page.

Источник

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

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.
Читайте также:  Linux mint шрифты microsoft

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

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

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

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 in action

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

tuptime date and time

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

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

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

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.

Источник

Оцените статью
Adblock
detector