You are not logged in.
Is there a way to have the CPU time spend by a processes and all the subprocesses it has spawned? Something like the time command but I want also the CPU time spent in the subprocesses that the main process has spawned. Some programs launches several subprocesses, in this cases just have the USER field of the time command is not very relevant. This is especially true for bash scripts but I see that some browsers also launch several subprocesses.
Last edited by olive (2011-02-26 19:27:09)
Offline
function child_search() {
ps --pid $1 -o bsdtime=
for pid in $(ps --ppid $1 -o pid=); do
child_search $pid
done
}
child_search $(pgrep firefox) | awk -F: '{minutes+=$1; seconds+=$2} END {print minutes ":" seconds}'
I don't know how/if this makes sense with threads though.
Offline
Thanks!
Offline