mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
commit
b21a061eb0
@ -7,36 +7,36 @@
|
||||
[#]: via: (https://www.2daygeek.com/bash-script-to-check-how-long-the-high-cpu-memory-consumption-processes-runs-on-linux/)
|
||||
[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/)
|
||||
|
||||
Bash Script to Check How Long the High CPU/Memory Consumption Processes Runs on Linux
|
||||
在 Linux 中运行 Bash 脚本检查高 CPU/内存消耗进程
|
||||
======
|
||||
|
||||
In the past, we have written three different articles to identify this using Linux commands.
|
||||
过去,我们写了三篇不同的文章来使用 Linux 命令来识别。
|
||||
|
||||
You can access them immediately by going to the relevant URLs below.
|
||||
你可以通过下面相关的 URL 立即访问。
|
||||
|
||||
* **[How to Find High CPU Consumption Processes in Linux][1]**
|
||||
* **[How to Find Out Top Memory Consuming Processes in Linux][2]**
|
||||
* **[Five Ways to Check How Long a Process Has Been Running in Linux][3]**
|
||||
* **[如何在 Linux 中查找高 CPU 消耗进程][1]**
|
||||
* **[如何找出 Linux 中的高内存消耗进程][2]**
|
||||
* **[检查进程在 Linux 中运行了多长时间的五种方法][3]**
|
||||
|
||||
|
||||
|
||||
Two scripts are included in this tutorial, which helps you to identify how long the high CPU/memory consumption processes are running on Linux.
|
||||
本教程中包含两个脚本,它们可以帮助你确定 Linux 上高 CPU/内存消耗进程的运行时间。
|
||||
|
||||
The script will show you the process ID, the owner of the process, the name of the process and how long the processes are running.
|
||||
该脚本将显示进程 ID,进程的所有者,进程的名称以及进程的运行时间。
|
||||
|
||||
This will help you identify which jobs are running overtime (which must be completed beforehand).
|
||||
这将帮助你确定哪些(必须事先完成)作业正在超时运行。
|
||||
|
||||
This can be achieved using the ps command.
|
||||
在可以使用 ps 命令来实现。
|
||||
|
||||
### What’s ps Command
|
||||
### 什么是 ps 命令
|
||||
|
||||
ps stands for processes status, it display the information about the active/running processes on the system.
|
||||
ps 代表进程状态,它显示有关系统上活动/正在运行的进程的信息。
|
||||
|
||||
It provides a snapshot of the current processes along with detailed information like username, user id, cpu usage, memory usage, process start date and time command name etc.
|
||||
它提供了当前进程的快照以及详细信息,例如用户名、用户 ID、CPU 使用率、内存使用率、进程开始日期和时间等。
|
||||
|
||||
### 1) Bash Script to Check How Long the High CPU Consumption Processes Runs on Linux
|
||||
### 1)Bash 脚本检查高 CPU 消耗进程在 Linux 上运行了多长时间
|
||||
|
||||
This script will help you to identify how long the high CPU consumption processes has been running on Linux.
|
||||
该脚本将帮助你确定高 CPU 消耗进程在 Linux 上运行了多长时间。
|
||||
|
||||
```
|
||||
# vi /opt/scripts/long-running-cpu-proc.sh
|
||||
@ -56,13 +56,13 @@ done | column -t
|
||||
echo "--------------------------------------------------"
|
||||
```
|
||||
|
||||
Set an executable **[Linux file permission][4]** to **“long-running-cpu-proc.sh”** file.
|
||||
给 **”long-running-cpu-proc.sh“** 设置可执行**[Linux 文件权限][4]**。
|
||||
|
||||
```
|
||||
# chmod +x /opt/scripts/long-running-cpu-proc.sh
|
||||
```
|
||||
|
||||
When you run this script, you will get an output like the one below.
|
||||
运行此脚本时,你将获得类似以下的输出。
|
||||
|
||||
```
|
||||
# sh /opt/scripts/long-running-cpu-proc.sh
|
||||
@ -82,9 +82,9 @@ daygeek 6301 Web 57:40
|
||||
----------------------------------------------------
|
||||
```
|
||||
|
||||
### 2) Bash Script to Check How Long the High Memory Consumption Processes Runs on Linux
|
||||
### 2)Bash 脚本检查高内存消耗进程在 Linux 上运行了多长时间
|
||||
|
||||
This script will help you to identify how long the top memory consumption processes has been running on Linux.
|
||||
该脚本将帮助你确定最大的内存消耗进程在 Linux 上运行了多长时间。
|
||||
|
||||
```
|
||||
# sh /opt/scripts/long-running-memory-proc.sh
|
||||
@ -104,13 +104,13 @@ done | column -t
|
||||
echo "--------------------------------------------------"
|
||||
```
|
||||
|
||||
Set an executable Linux file permission to **“long-running-memory-proc.sh”** file.
|
||||
给 **”long-running-memory-proc.sh“** 设置可执行 Linux 文件权限。
|
||||
|
||||
```
|
||||
# chmod +x /opt/scripts/long-running-memory-proc.sh
|
||||
```
|
||||
|
||||
When you run this script, you will get an output like the one below.
|
||||
运行此脚本时,你将获得类似以下的输出。
|
||||
|
||||
```
|
||||
# sh /opt/scripts/long-running-memory-proc.sh
|
||||
@ -136,7 +136,7 @@ via: https://www.2daygeek.com/bash-script-to-check-how-long-the-high-cpu-memory-
|
||||
|
||||
作者:[Magesh Maruthamuthu][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
Loading…
Reference in New Issue
Block a user