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?

1 Answer 1


You could do something like:

mv my-executable my-executable.bin

And create my-executable as a wrapper script that does:

#! /bin/bash -
{ time "$0.bin" "$@" 2>&3 3>&-; } 3>&2 2>> /tmp/times.log

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)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .