we would need to know how much memory and cpu time a matlab process had used with all of it’s spawned threads. If I understand it correctly, all the threads will pop up as new processes with new process-ids but the CMD name will remain the same.
so I thought about creating a demon which append the usage in every n sec:
ps -o %cpu,%mem,cmd -C MATLAB | grep "[0-9]+" >> matlab_log
and later counting and summing up the ratios multiplied by the demon tick time.
I wonder if there is an easier way, or I missing something, or simply just exist some tool more handy for this job?
Cheers
If you install the BSD Process Accounting utilities (package
accton Debian and Ubuntu) you can use thesa(8)utility to summarize executions or give you semi-detailed execution logs:The format of the
acctfile is documented inacct(5), so you could write your own programs to parse the files if none of the standard tools lets you express the queries you want.Probably the largest downside to the BSD process accounting utilities is that the kernel will only update the process accounting log when processes exit, because many of the summary numbers are only available once another process
wait(2)s for it — so currently running processes are completely overlooked by the utilities.These utilities may be sufficient though; these utilities is how compute centers billed their clients, back when compute centers were popular…