LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 09-02-2010, 02:27 AM   #1
kgarg29
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, 04:03 AM   #2
pkhera_2001
Member
 
Registered: Mar 2006
Location: New Delhi, India
Distribution: Fedora, CentOS, RHEL, Ubuntu
Posts: 67

Rep: Reputation: 18
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,
 
Old 09-02-2010, 05:06 PM   #3
linux_hy
Member
 
Registered: Oct 2006
Posts: 66

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


Reply


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 07:46 AM
How to get the memory usage of myself process (GetProcessMemoryInfo() 4 linux)? faristol Programming 2 04-24-2009 08:41 AM
how to programmatically monitor a process memory usage? thanhvn Programming 14 02-20-2009 01:15 AM
how to programmatically monitor a process memory usage? thanhvn Linux - Software 1 11-15-2005 08:44 PM


All times are GMT -5. The time now is 03:51 AM.

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