如何监控进程的内存使用- ubuntu

时间:2021-07-08 03:41:32

I want to watch a given process in unix over time to see what time memory grows (its a long running job)

我想观察unix中给定的进程随时间增长的情况(这是一项长期的工作)

I guess I could do

我想我可以

ps -aux | grep PID

and run this from cron every 5 minutes, but it seems there should be a better way.

每5分钟从cron那里运行一次,但似乎应该有更好的方法。

Is there a way I can use sar to do this?

我有办法用sar来做吗?

1 个解决方案

#1


21  

I use this:

我用这个:

$ ps -o rss $(pgrep executablename)

Put that in a while loop or use watch to monitor it over time coupled with tail. You can also tee it to a file and have gnuplot plot it for you and refresh every few seconds.

将其放入一个while循环中,或者使用watch随着时间的推移与tail一起监控。您还可以将它赋值到一个文件,并让gnuplot为您绘制它,并每隔几秒钟刷新一次。

#1


21  

I use this:

我用这个:

$ ps -o rss $(pgrep executablename)

Put that in a while loop or use watch to monitor it over time coupled with tail. You can also tee it to a file and have gnuplot plot it for you and refresh every few seconds.

将其放入一个while循环中,或者使用watch随着时间的推移与tail一起监控。您还可以将它赋值到一个文件,并让gnuplot为您绘制它,并每隔几秒钟刷新一次。