[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Monitoring CPU usage of a process

Adar Dembo wrote:
> I have some processes whose cpu usage I would like to monitor, and pipe
> into a file. As far as I know, top can't monitor a single process and
> send its cpu usage into a file, so I'm wondering what other programs
> might do this. This is a testing installation, on a computer without any
> GUI or anything sophisticated like that. Any help is greatly
> appreciated.

How about ps piped through grep and then sent to the file?  

ps -Al | grep foo >> bar

If you just want cpu usage percent, try this:

ps -Ao "comm pcpu" | grep foo >> bar 

Make it into a simple shell script with a loop and a delay if you want a
periodic output.  Add a call to date if you want timestamps.

while sleep 10; do
	date +%H:%M:%S >> bar
	ps -Ao "comm pcpu" | grep foo >> bar

There's about a million ways to skin this cat.


To UNSUBSCRIBE, email to debian-user-request@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Reply to: