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

查看:94
本文介绍了检索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天全站免登陆