I have a bash script which runs a series of programs which run other programs . How would I get the cpu time of the bash script and all of it descendants processes.
I looked in /proc/{process-id}/stat and the question How to calculate the CPU usage of a process by PID in Linux from C?
but I am not sure how I would calculate the total cpu time for all the child processes of the bash script.
Edit If I calculate difference in utime and difference in stime for some time interval, I know for a single process the cpu time (utime + stime) it took in that interval.
How would I add up the cpu time for all the child processes (which also create their own processes) while the process is still running?