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.

Currently I'm using the following to check how long a process is actually running:

ps -eo uid,pid,etime | egrep '^ *MY_ID' | egrep 'PID_OF_PROCESS'

And that outputs the following:

MY_ID PID_OF_PROCESS       00:16

However, after the process ends I want to find out how long it actually ran for but I can't seem to find that information.

share|improve this question
add comment

2 Answers

up vote 8 down vote accepted

I don't think it is possible to obtain such information after the process has already finished.

If you know beforehand that you will need that information, you can run the command as

time <command>

e.g.

~> time sleep 1

real        0m1.003s
user        0m0.002s
sys         0m0.001s
share|improve this answer
add comment

Check if your unix variant supports process accounting. For example, on Ubuntu (and most other Linux distributions), this is provided by the acct package Install acct. If the accounting subsystem is up and running, then lastcomm shows information about finished processes, including how much processor time they used (the wall clock time isn't recording).

If you need timing for a specific program, invoke it through time.

If you need more precise information, use a fancier auditing package, for example the audit subsystem under Linux.

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.