Посмотреть uptime сервера linux

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.

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.

Источник

Читайте также:  Характеристика операционных систем семейства linux

How to Check Server Uptime in Linux

Server Uptime

Server uptime is an important metric that indicates how long a system has been running without interruption. In Linux, there are several commands that you can use to check server uptime, including uptime, w, and top.

In this guide, we’ll cover these commands, along with a few other methods to determine the server uptime.

Method 1: The uptime Command

The uptime command is the most straightforward way to check server uptime in Linux. It displays the current time, system uptime, the number of users, and the load average. To use the uptime command, simply run:

The output will show the uptime in days, hours, and minutes, along with other system information.

22:54:34 up 1:26, 1 user, load average: 0.11, 0.03, 0.01
  • The current time (22:54:34)
  • How long the system has been up and running (1 hour 26 Minutes)
  • How many users are currently logged in (1 user)
  • The system load averages for the past 1, 5, and 15 minutes (0.11, 0.03, 0.01)

Method 2: The w Command

The w command provides information about the system’s current users and what they are doing, along with the server uptime. To use the w command, run:

The first line of the output displays the current time, system uptime, the number of users, and the load average, similar to the uptime command.

23:06:57 up 1:38, 1 user, load average: 0.00, 0.00, 0.00 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT root pts/0 192.168.1.52 21:30 0.00s 1.85s 0.01s w

Method 3: The top Command

The top command is a real-time system monitoring tool that provides an overview of the system’s processes and resource usage. It also displays the server uptime. To use the top command, run:

The server uptime is displayed at the top of the output, next to the current time and the system load averages.

23:27:01 up 4 days, 10:20, 1 user, load average: 0.22, 0.12, 0.09 Tasks: 163 total, 1 running, 162 sleeping, 0 stopped, 0 zombie %Cpu(s): 6.1 us, 1.0 sy, 0.0 ni, 92.7 id, 0.1 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 4043436 total, 282644 free, 1044916 used, 2715876 buff/cache KiB Swap: 8388600 total, 8316440 free, 72160 used. 2905352 avail Mem

To exit the top command, press q.

Method 4: The /proc/uptime File

Linux stores the server uptime in seconds in the /proc/uptime file. You can check the contents of this file to determine the server’s uptime. To do this, run:

The output shows two values: the system uptime in seconds and the idle time in seconds. You can use awk to convert the uptime value to a more human-readable format:

This command will display the server uptime in days, hours, and minutes.

Method 5: The sysinfo Command (not available on all systems)

On some Linux distributions, you can use the sysinfo command to display various system information, including server uptime. To use the sysinfo command, run:

The server uptime is displayed in the output along with other system information.

Method 6: The who Command with -b Option

The who command can display various information about users on the system, but it also has a -b option that shows the last system boot time. To use the who command with the -b option, run:

The output displays the last system boot time. You can calculate the server uptime by subtracting the boot time from the current time.

Читайте также:  Install linux binary file

Method 7: The last Command with -x Option

The last command displays the history of user logins on the system. By using the -x option, you can also see information about system shutdowns and reboots. To use the last command with the -x option, run:

Look for the most recent “system boot” entry in the output. This indicates the last time the system was rebooted, from which you can calculate the server uptime.

Method 8: Using systemd-analyze

For systems using systemd, you can use the systemd-analyze command to check the server uptime. To do this, run:

The output displays the time elapsed since the last system boot. Note that this command may not be available on all Linux distributions.

Commands Mentioned:

  • uptime – Displays system uptime, current time, the number of users, and the load average.
  • w – Provides information about the current users and their activity, along with system uptime and load average.
  • top – Monitors system processes and resource usage in real-time, and shows server uptime.
  • cat /proc/uptime – Displays the server uptime in seconds from the /proc/uptime file.
  • sysinfo – Shows various system information, including server uptime (not available on all systems).
  • who -b – Displays the last system boot time.
  • last -x – Shows the history of user logins, system shutdowns, and reboots.
  • systemd-analyze – Checks the server uptime on systems using `systemd` (may not be available on all Linux distributions).

Conclusion

In this guide, we have covered multiple methods for checking server uptime in Linux, including the uptime, w, top, /proc/uptime, sysinfo, who, last, and systemd-analyze commands. By using these tools, you can easily monitor your server’s uptime and ensure that it is running smoothly and reliably.

Please feel free to leave comments and suggest improvements to this guide. Your feedback is valuable and helps us improve our content for our audience.

Dimitri Nek

Dimitri is a Linux-wielding geek from Newport Beach and a server optimization guru with over 20 years of experience taming web hosting beasts. Equipped with an arsenal of programming languages and an insatiable thirst for knowledge, Dimitri conquers website challenges and scales hosting mountains with unmatched expertise. His vast knowledge of industry-leading hosting providers allows him to make well-informed recommendations tailored to each client’s unique needs.

Источник

Linux Uptime Command

Any Linux distro comes with the “uptime” command. It’s an important command for system administrators to know. It helps troubleshoot the issues related to power and scheduling. Of course, there are other alternative tools available for this purpose but uptime is relatively simple and easy to use.

The content of this guide is as follows:

Let’s start the uptime command.

How Does the Uptime Command Work?

If you use the system’s uptime command via command prompt, you get many benefits out of it. For example, suppose you are facing a problem in connecting to the server. Then, you can easily run the uptime command on the server to check if there has been a recent reboot on the server. This helps in troubleshooting the situation and provides you with better visibility to apply the required solution.

The output specifies the current time. “Up” specifies that the system is up and running along with the total time that the system is up to the user count and the system load averages.

Читайте также:  Linux сочетание клавиш вырезать

Running the uptime command of a Linux system via the command line, you get a specified output in the following order:

  • The current time of the system.
  • The total uptime of the system.
  • The active users that are currently running the system.
  • The average of the system loads that is available for the past 1, 5, and 15 minutes.

Uptime command comes with various options. To check the options, we can run the “help” command.

Example 1: Uptime in Human-Readable Format

With the use of the “-p” option, you can get a pretty clear output which displays the uptime in the number of days, hours, minutes, and seconds format:

Example 2: Check the Start Time of the System

Another option is to check the exact time when the system is first started rather than the time spent since it started. Run the following command on the command-line interface with the “-s” option:

Example 3: Check the Version of the Installed Uptime Command

If you want to check the version of the installed uptime package in the system, run the following command with the “-V” option:

The output shows the current version of the “uptime” command.

Conclusion

Linux is a well-known environment and is highly recommended for various projects due to its stability and various configurations. The “uptime” command checks the system information. We explained the “uptime” command with its various options.

About the author

Syed Minhal Abbas

I hold a master’s degree in computer science and work as an academic researcher. I am eager to read about new technologies and share them with the rest of the world.

Источник

Команда Uptime в Linux

Favorite

Добавить в избранное

Команда Uptime в Linux

Как следует из названия, основная цель команды uptime — показать, как долго работает система. Также будет отображаться текущее время, количество зарегистрированных пользователей и средняя загрузка системы.

Как использовать команду Uptime

Синтаксис для команды uptime следующий:

Чтобы отобразить время работы системы, вызовите команду без каких-либо опций:

Вывод будет выглядеть примерно так:

12:35:19 up 8 min, 1 user, load average: 0.66, 0.62, 0.35
  • 12:35:19 — текущее системное время.
  • up 8 min — это время, в течение которого система работала.
  • 1 user количество зарегистрированных пользователей.
  • load average: 0.66, 0.62, 0.35 — средние значения загрузки системы за последние 1, 5 и 15 минут.

Средняя нагрузка на Linux может немного сбивать с толку. В отличие от других операционных систем, которые показывают средние значения загрузки процессора, Linux показывает средние значения загрузки системы.

Средняя загрузка системы измеряет количество заданий, которые в данный момент выполняются или ожидают дискового ввода-вывода. В основном это говорит о том, насколько занята ваша система в течение заданного интервала.

Если средние значения нагрузки равны 0,0, то система в основном простаивает. Если среднее значение нагрузки за последние 1 минуту выше, чем среднее значение за 5 или 15 минут, то нагрузка увеличивается, в противном случае нагрузка уменьшается. Средняя нагрузка увеличивается из-за более высокой загрузки процессора, нагрузки на диск.

Параметры команды Uptime

Команда uptime принимает только несколько опций, которые используются редко.

Опция -p, —pretty указывает uptime отображать вывод в симпатичном формате:

Вывод покажет только, как долго работает система:

Опция -s, —since показывает дату и время с момента запуска системы:

Заключение

Команда uptime легко запоминается и дает вам информацию о текущем времени, онлайн-пользователях, длительности работы вашей системы и средней загрузке системы.

Если вы нашли ошибку, пожалуйста, выделите фрагмент текста и нажмите Ctrl+Enter.

Источник

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