2

I got a parent and a child process running, I know their IDs.

How do I utilize 'ps' and 'watch' to filter them out, so that I can see their used CPU times?

I tried 'watch ps -u USERNAME', but as you can imagine there are a lot more processes than the desired ones.

1 Answer 1

3

If the PIDs are e.g. 340 and 520, then you can try the following:

$ watch --interval 2 --difference "ps -p 340,520 -o pid,ppid,%cpu,cputime"

Here watch will mark the difference of outputs running with 2 seconds interval, here we have used the output formatting -o option to get only process ID (pid), parent process ID (ppid), percentage of cpu utilization (%cpu) and the cpu time (cputime).

Check man ps for more ps output formatting options.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.