Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to check the boot running time of Linux

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to check the boot running time of Linux", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to check the boot time of Linux".

1. Uptime command

The code is as follows:

Homer@ubuntu:~$ uptime

19:34:40 up 4 days, 4:18, 6 users, load average: 0.00, 0.01, 0.05

It shows in turn: the current time of the system, how long the system has been running, how many login users there are, and the average load of the system in the past 1 minute, 5 minutes, and 15 minutes.

19:34:40 indicates the current time of the system

4 days, 4:18 indicates the duration of the system operation, that is, it has been running continuously for 4 days, 4 hours and 18 minutes.

View user: who

The code is as follows:

Homer@ubuntu:~$ who

Homer tty7 2014-04-10 15:20

Homer pts/0 2014-04-10 15:22 (: 0)

Homer pts/2 2014-04-10 16:03 (: 0)

Homer pts/3 2014-04-10 19:46 (: 0)

Homer pts/4 2014-04-11 17:34 (: 0)

Homer pts/6 2014-04-14 19:34 (172.27.22.17)

two。 Check the / proc/uptime file to calculate the system startup time

The code is as follows:

Homer@ubuntu:~$ cat / proc/uptime

361481.06 1412691.64

Output: 361481.06 1412691.64

The first number is the time the system has been running for 5113396.94 seconds.

1) Calculator calculation: 361481.06 / 3600 / 24 = 25.1028 (days)

2) calculate the startup time of the system by using the system tool date

The code is as follows:

Homer@ubuntu:~$ date-d "$(awk-F.'{print $1}'/ proc/uptime) second ago" + "% Y-%m-%d% H:%M:%S"

2014-04-10 15:16:41

3. View the / proc/uptime file to calculate the system run time

The code is as follows:

Homer@ubuntu:~$ cat / proc/uptime | awk-F. '{run_days=$1 / 86400X runaway minutes hourly = ($1% 86400) / 3600th runners minute = ($1% 3600) / 60th runners secondhands 1% 60ash printf ("system has run:% d days% d hours% d minutes\ n", run_days,run_hour,run_minute,run_second)}'

The system is running: 04:30:04 on the 4th

Output: system running: 04:30:04 on the 4th day

4. View the process run time:

1) start time of the process:

The code is as follows:

Root@ubuntu:/# ps-eo lstart

STARTED

Thu Apr 10 15:16:40 2014

Thu Apr 10 15:16:40 2014

Thu Apr 10 15:16:40 2014

2) running time of the process:

The code is as follows:

Root@ubuntu:/# ps-eo etime

ELAPSED

4-04:50:20

4-04:50:20

4-04:50:20

3) View the start / run time of the process:

The code is as follows:

Root@ubuntu:/# ps-eo uid,pid,ppid,cmd,lstart,etime

UID PID PPID CMD STARTED ELAPSED

01 0 / sbin/init Thu Apr 10 15:16:40 2014 4-04:51:50

20 [kthreadd] Thu Apr 10 15:16:40 2014 4-04:51:50

0 32 [ksoftirqd/0] Thu Apr 10 15:16:40 2014 4-04:51:50

0 52 [kworker/u:0] Thu Apr 10 15:16:40 2014 4-04:51:50

0 62 [migration/0] Thu Apr 10 15:16:40 2014 4-04:51:50

0 7 2 [watchdog/0] Thu Apr 10 15:16:40 2014 4-04:51:50

5. Graphical tools:

Bootchart is an open source software tool for performance analysis of linux startup process, which automatically collects CPU occupancy, process and other information during system startup, and displays the analysis results graphically, which can be used to guide and optimize the system startup process.

To install and view bootchart on Debian/Ubuntu:

1) install sudo apt-get install bootchart

2) restart the system: sudo reboot

3) the generated bootchart image will be saved in the / var/log/bootchart/ directory and opened with GNOME image viewer

The code is as follows:

Eog / var/log/bootchart/ubuntu-precise-20140414-1.png

4) the generated bootchart image is as follows:

At this point, I believe you have a deeper understanding of "how to check the boot running time of Linux". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report