惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
T
Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
H
Hackread – Cybersecurity News, Data Breaches, AI and More
I
Intezer
C
Cyber Attacks, Cyber Crime and Cyber Security
The Register - Security
The Register - Security
量子位
Security Latest
Security Latest
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
C
CXSECURITY Database RSS Feed - CXSecurity.com
MyScale Blog
MyScale Blog
J
Java Code Geeks
Apple Machine Learning Research
Apple Machine Learning Research
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
Spread Privacy
Spread Privacy
Jina AI
Jina AI
博客园 - 【当耐特】
P
Palo Alto Networks Blog
Last Week in AI
Last Week in AI
SecWiki News
SecWiki News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
G
GRAHAM CLULEY
宝玉的分享
宝玉的分享
Hacker News - Newest:
Hacker News - Newest: "LLM"
T
The Blog of Author Tim Ferriss
V
Vulnerabilities – Threatpost
有赞技术团队
有赞技术团队
T
Tor Project blog
H
Hacker News: Front Page
A
Arctic Wolf
NISL@THU
NISL@THU
A
About on SuperTechFans
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
V
V2EX
N
News and Events Feed by Topic
Webroot Blog
Webroot Blog
Know Your Adversary
Know Your Adversary
P
Privacy International News Feed
I
InfoQ
D
Docker
L
LINUX DO - 最新话题
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
U
Unit 42

博客园 - yeren2046

RedCoins,一个免费的类似bluecoins的个人财务管理软件 记录一个栈溢出导致的崩溃问题 一个免费的图片数据标注工具 常用zip命令 git版本导致的"Permission denied (publickey). fatal: Could not read from remote repository." linux 上用 core 文件定位线上问题 ffmpeg 时基转换 昇腾卡通道号范围 ffmpeg视频截取 英伟达硬解码错误汇总 DVPP问题汇总 TensorRT生成INT8校准文件 结构体指定初始化 ffmpeg命令行基于英伟达显卡编解码的转码 C++11 获取当前时间戳 基于CUDA查询显卡型号和显存大小 nvjpeg 简单使用 AV_PIX_FMT_CUDA 数据转 RGB C++ do{ } while(0)
只显示全部特定进程名的top信息的shell脚本
yeren2046 · 2025-11-07 · via 博客园 - yeren2046

1. 脚本代码

#!/bin/bash

# 使用 pgrep 获取所有名为 nginx 的进程的 PID,并用逗号分隔
EXE_NAME=$1

#包含名称即可
# NGINX_PIDS=$(pgrep -d, $EXE_NAME)
#名称必须完全匹配
NGINX_PIDS=$(pidof $EXE_NAME | tr ' ' ',')

# 检查是否找到任何进程
if [ -n "$NGINX_PIDS" ]; then
    # 使用 top 单次输出这些 PID 的信息
    top -b -n 1 -p  $NGINX_PIDS
else
    echo "No processes found with name '$EXE_NAME'."
fi

脚步文件命名为top.sh,注意给脚步添加可执行权限 chmod +x top.sh.

此脚步为单次输出信息.

2. 定时刷新

配合上watch命令,实现定时刷新信息

watch -n  0.1 ./top.sh demo

这里查看名称为demo的进程的top信息,每0.1s更新一次

效果如下:

top


ec878be9becfe6e164bdfb5ba75ca6815baf8e427cc615c1034e4daf432d4872

posted @ 2025-11-07 10:58  yeren2046  阅读(32)  评论(0)    收藏  举报