3

I know the time command allows you to time the execution of a given command. But is it possible to get the execution time of the previous command without re-executing that previous command?

1
  • 2
    Only if it happened to log something somewhere at the beginning and end of its run, and both entries included a timestamp.
    – Sammitch
    Feb 20, 2013 at 21:38

1 Answer 1

11

If you run around the block and don't measure the amount of time it took, didn't watch any clocks before, during or after and no people saw you do it, you also don't know how long it takes on average; would you be able to tell how long it took you to run around the block?

No.


At best, you can know when you launched a certain application.

HISTTIMEFORMAT="%F %T " history

But that doesn't tell you when it has ended, which you will need to deduce, if at all possible.

2
  • 3
    It could have been possible that the duration of every command was stored temporarily somewhere. I would have found it surprising if it was like that but it's not like I haven't been surprised before, no need to be patronizing. That command to know when a command was launched is good to know however, thanks.
    – Bentley4
    Feb 20, 2013 at 22:01
  • 3
    @Bentley4: If there were such thing, there would have been an option for that in the kernel; there are options for that, but these options are tracing tools that aren't enabled by default which brings it down to needing to turn on the tracing in advance. The only remaining thing I can think off is an ability to know when you gained back your input (so you can do $input_time - $last_history_touch), but I don't know if that is kept track of anywhere. Maybe you can set up something preventive that allows you to determine the run time of any prior process at any point in time... Feb 20, 2013 at 22:07

You must log in to answer this question.

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