I know how to monitor a process. Commands like top
and so forth can monitor the CPU time and memory usage for a given process instance.
But say I expect a given executable to be run several times in the next hour, and I want to measure how many times it is run and the CPU time it has consumed. What's a command for that?
Best Answer
You could do something like:
And create
my-executable
as a wrapper script that does:The script could add more information to the log like the time it was started, by whom, the arguments it was passed...
BSD process accounting, at least on Linux does report CPU time (user + sys), though not in a cumulative way like
time
does (children processes CPU time is not accounted for the parent)