Possible Duplicate:
Measure script execution time

How would I time how long it takes for my script foo.sh to run?

I'm looking for something akin to tic and toc in MATLAB.

marked as duplicate by Wuffers, studiohack Apr 4 '11 at 1:52

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


Use the unix time command

time ./sript.sh

If you're interested in ticks, you can approximate it with a little help from /proc/cpuinfo

  • 2
    time is a shell keyword – Hello71 Apr 25 '11 at 23:21
  • 1
    @Hello71 my linux bash does not provide a time command, it uses /usr/bin/time. However zsh does, as well as my solaris tcsh. So even if it's not builtin your shell, you have a time provided by your userland as a fallback. Besides, those time commands may provide a slightly different output. – mbx Apr 26 '11 at 9:45
  • @Hello71 although reserved, on that ystem which time returns userland time instead of the reserved keyword warning – mbx Apr 26 '11 at 21:20
  • @mbx: which never does that. I'm referring to type. – Hello71 Apr 26 '11 at 21:21

time can achieve this. In this case:

$ time foo.sh             

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