开发者

How to log the Ram and CPU usage for Linux Processes

开发者 https://www.devze.com 2023-03-18 01:59 出处:网络
How would I track the CPU and Ram usage for a process that may run, stop, and then re-run with a diffe开发者_StackOverflow中文版rent PID?

How would I track the CPU and Ram usage for a process that may run, stop, and then re-run with a diffe开发者_StackOverflow中文版rent PID?

I am looking to track this information for all processes on a Linux server but the problem is when the process stops and restarts, it will have a different PID and I am not sure how to identify it as the same process.


What you're looking for here is called "process accounting".

http://tldp.org/HOWTO/Process-Accounting/


If you know the command of the process, just pipe it to a grep like this:

ps ux | grep yourcommandgoeshere


You can setup a crontab to record output of commands like

  1. top -b -n1 | grep
  2. ps ux | grep

Alternatively, you can use sealion service. By simply installing agent and configuring it according to your needs in simple steps, you can see output of the executed commands online.

Hope it helps...

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号