在 Linux 上检索单个进程的 CPU 使用率和内存使用率? [英] Retrieve CPU usage and memory usage of a single process on Linux?

查看:30
本文介绍了在 Linux 上检索单个进程的 CPU 使用率和内存使用率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 Linux 上获取单个进程的 CPU 和内存使用情况 - 我知道 PID.希望我能每秒获取它并使用watch"命令将其写入 CSV.我可以使用什么命令从 Linux 命令行获取此信息?

I want to get the CPU and memory usage of a single process on Linux - I know the PID. Hopefully, I can get it every second and write it to a CSV using the 'watch' command. What command can I use to get this info from the Linux command-line?

推荐答案

ps -p <pid> -o %cpu,%mem,cmd

(您可以省略cmd",但这可能有助于调试).

(You can leave off "cmd" but that might be helpful in debugging).

请注意,这给出了进程在运行期间的平均 CPU 使用率.

Note that this gives average CPU usage of the process over the time it has been running.

这篇关于在 Linux 上检索单个进程的 CPU 使用率和内存使用率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆