Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 09-02-2010, 03:27 AM   #1
LQ Newbie
Registered: Feb 2008
Posts: 1

Rep: Reputation: 0
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.
Old 09-02-2010, 05:03 AM   #2
Registered: Mar 2006
Location: New Delhi, India
Distribution: Fedora, CentOS, RHEL, Ubuntu
Posts: 67

Rep: Reputation: 18

You can use following script:

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

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.

Old 09-02-2010, 06:06 PM   #3
Registered: Oct 2006
Posts: 66

Rep: Reputation: -2
you can make a shell script with pmap


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get the each process actual RAM memory usage in linux 2.6.21 or higher version rangrej25 Linux - General 2 02-08-2010 08:46 AM
How to get the memory usage of myself process (GetProcessMemoryInfo() 4 linux)? faristol Programming 2 04-24-2009 09:41 AM
how to programmatically monitor a process memory usage? thanhvn Programming 14 02-20-2009 02:15 AM
how to programmatically monitor a process memory usage? thanhvn Linux - Software 1 11-15-2005 09:44 PM

All times are GMT -5. The time now is 09:57 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration