Find the answer to your Linux question:
Results 1 to 3 of 3
Hi all, I want to monitor the CPU percentage using the shell script which i am going to put it under cron tab to be scheduled for running every 10 ...
  1. #1
    Just Joined!
    Join Date
    Feb 2009
    Location
    Chennai, India
    Posts
    28

    Shell script to monitor process which uses more CPU



    Hi all,

    I want to monitor the CPU percentage using the shell script which i am going to put it under cron tab to be scheduled for running every 10 mins once.

    I need to monitor the top 5 process which uses more CPU percentage. I am looking for a command which does this one.

    Note: I am on RHEL 5 Enterprise Server

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
    Posts
    8,499
    What about using the top command? Note that a process that has multiple threads can exceed 100% CPU if you have more than one CPU or core. You can run it in batch mode if you want to output this data to a file.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Feb 2009
    Location
    Chennai, India
    Posts
    28
    Rubberman thanks for your time. I tried your suggestion by invoking top like this

    top -bn 5 > toplog

    Where the process are sorted out by CPU percentage.But this output has more details as it capture all the process. Here what i need is, i want to list only the top 5 of them. Is there a way i can cut those extra details from the top command so that i can concentrate on top 5 process only.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •