Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

How to monitor thread/CPU/memory usage of a particular process

  • 05-06-2008 10:20am
    #1
    Registered Users, Registered Users 2 Posts: 5,659 ✭✭✭


    Can anyone help with this?

    Im looking to take a simple snapshot of a particular process. I know of top, prstat, ps -ef ETC ETC but they all give long lists. Just want a simple script/command to look at one process

    Also, i only know the process by name, not PID so will probably need some funky code to get the PID i guess...

    Thanks for any help! :pac:


Comments

  • Moderators, Science, Health & Environment Moderators Posts: 10,088 Mod ✭✭✭✭marco_polo


    Can anyone help with this?

    Im looking to take a simple snapshot of a particular process. I know of top, prstat, ps -ef ETC ETC but they all give long lists. Just want a simple script/command to look at one process

    Also, i only know the process by name, not PID so will probably need some funky code to get the PID i guess...

    Thanks for any help! :pac:

    Something like ps -ef | grep [process name] will return just the line you are intersted in and you could then extract the PID from that (Please don't ask me how :p).


  • Closed Accounts Posts: 2,267 ✭✭✭h57xiucj2z946q


    Can anyone help with this?

    Im looking to take a simple snapshot of a particular process. I know of top, prstat, ps -ef ETC ETC but they all give long lists. Just want a simple script/command to look at one process

    Also, i only know the process by name, not PID so will probably need some funky code to get the PID i guess...

    Thanks for any help! :pac:


    you can use pgrep to get pid of a process by name. this can return more than 1 result by the way.

    prstat can be used with -p option for listing of single process.


  • Closed Accounts Posts: 2,267 ✭✭✭h57xiucj2z946q


    if you have a unique process, that is, only 1 instance of it executed on the system, then you could use:

    prstat -p `pgrep xclock`

    there backticks, not quotes (above the tab key)


  • Registered Users, Registered Users 2 Posts: 2,082 ✭✭✭Tobias Greeshman


    marco_polo wrote: »
    Something like ps -ef | grep [process name] will return just the line you are intersted in and you could then extract the PID from that (Please don't ask me how :p).

    Something like this should work, I haven't tried this out:
    ps -ef | grep <process | grep -v grep | cut -f 3 -d ' '

    Change the -f number until you get the right number


  • Registered Users, Registered Users 2 Posts: 5,659 ✭✭✭veryangryman


    Thats cool but how would you specifically get the CPU for instance?

    Those ps -ef command only gives the PID


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 545 ✭✭✭ravydavygravy


    I think this is what you are looking for:
    ps -eo comm,uid,pid,%cpu,%mem | grep <name-of-process>
    

    Have a look at the man page for ps, to see what other information you can print out.

    ~Dave


Advertisement