Operating System - HP-UX
1847127 Members
5554 Online
110263 Solutions
New Discussion

Re: Proc name & %CPU utilization

 
SOLVED
Go to solution
Joseph Chakkery
Valued Contributor

Proc name & %CPU utilization

Hello All,

Is there any option for ps command, which will give process id , proc name and %CPU utilization. I know top will give this. But What I want is to grep these details and send to my mail id through a cron job. I can't pipe the output of top command. If there is an option for ps it will be easy. Any idea's?

Thanks in advance.

Regards
Joe.
Knowledge is wealth
3 REPLIES 3
James R. Ferguson
Acclaimed Contributor
Solution

Re: Proc name & %CPU utilization

Hi Joseph:

You *can* use 'top'. There is a relatively unknown option to allow collection into a file:

'top -f ' will do the trick:

# top -d 1 /tmp/top.out

Regards!

...JRF...
Joseph Chakkery
Valued Contributor

Re: Proc name & %CPU utilization

Thanks James.
I will work around on this by creating a script. Once again thanks.

Regards
Joe.
Knowledge is wealth
Bill Hassell
Honored Contributor

Re: Proc name & %CPU utilization

man ps

Actually, the explanation concerning XPG4 options is a bit foggy. Here is the answer to your question with some enhancements:

UNIX95= ps -eo pcpu,pid,args | more

The percent CPU is first, PID second and the command line is last. But the order is in kernel proctable order. Here is %CPU sorted largest first:

UNIX95= ps -eo pcpu,pid,args | sort -rn | more

There are very useful options such as -C and -H as well as -o, all enable with UNIX95 defined (just for the duration of the command).


Bill Hassell, sysadmin