Take the 2-minute tour ×
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.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.