LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   monitor memory usage of a process in linux (http://www.linuxquestions.org/questions/linux-software-2/monitor-memory-usage-of-a-process-in-linux-829889/)

kgarg29 09-02-2010 02:27 AM

monitor memory usage of a process in linux
 
How can I periodically monitor memory usage of a process in linux.Can it be dumped in some file.So that later I can see what was the process behaviour in taking memory.

pkhera_2001 09-02-2010 04:03 AM

Hi,

You can use following script:

#!/bin/bash
_pid=`echo $1`
_output=`touch /tmp/$_pid_file.txt`
_interval=`echo $2`
while true;
do
top -b -n1 | grep $_pid >> $_output
sleep $_interval;
done

Save above script in a file and execute it with process id an interval values:
/bin/bash <file name> <process pid> <interval>

Where as process id is the numeric id of process which you wish to monitor and interval is in seconds for time difference between each execution of script.

Thanks,

linux_hy 09-02-2010 05:06 PM

you can make a shell script with pmap


All times are GMT -5. The time now is 04:48 PM.