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

Linux to view memory-consuming process scripts

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

# Linux View memory-consuming processes #! / bin/bash

Echo-e `date +% y% m% d% H% M`

Echo-e "PID\ t\ tMem\ t\ tProc_Name"

# take out all the directories named by numbers under the / proc directory (the process name is the number is the process, and other information such as sys,net is stored)

For pid in `ls-l / proc | grep ^ d | awk'{print $9}'| grep-v [^ 0-9] `

Do

If [$pid-eq 1]; then continue;fi

Grep-Q "VmRSS" / proc/$pid/status 2 > / dev/null

If [$?-eq 0]; then

Mem=$ (grep VmRSS / proc/$pid/status\

| | gawk'{sum+=$2;} END {print sum}') |

Proc_name=$ (ps aux | grep-w "$pid" | grep-v grep\

| | awk'{for (iTun11witi |

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