LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   process memory history (https://www.linuxquestions.org/questions/linux-newbie-8/process-memory-history-4175606568/)

43L@eudc 05-24-2017 04:40 AM

process memory history
 
Hi,

I am Angel a newbie...I have a question.

Does anybody know how to check the history of which process took up high memory usage for past hours or days? is there such a log for this?

Many Thanks

pan64 05-24-2017 05:02 AM

in general it is not stored, but obviously there is a way (there are several ways) available to monitor a system and you can collect/access these information.
https://www.linux.com/blog/5-command...ry-usage-linux

syg00 05-24-2017 05:59 AM

To do historical analysis you need a tool that can monitor per process and store the data automatically for all processes. This has never been a standard Linux.
collectl and collectd are two examples - both require some setup prior to the events you want to investigate. Then you can query variously.

dejank 05-24-2017 06:07 AM

Not that I know off, but it can be achieved with some small bash scripts. For example:

https://stackoverflow.com/questions/...ption-on-linux

Also, you could use combinations of watch and ps, in this way:

Code:

watch 'ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | head'
When you see what it does, you could redirect its output to some file, or even use tee command to both display output in terminal and append it to some file. Use man watch, man ps and man tee to find some solution that you will be satisfied with, like what intervals you want to watch and how to achieve that with watch command. You could also use something like:

Code:

ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | head >> watchlog
That will give you output of top 9 processes by cpu usage(replace that part with --sort=-%mem to get by memory usage) and append it to file watchlog. If you set it as cron job, it could give you what you want. Just remember to clean that file from time to time, or to make bash script that will do that for you and run it every week, month or so.


All times are GMT -5. The time now is 02:34 PM.