Process – Check How Long a Process Ran After Finishing

process

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.

Best Answer

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