Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.