How to log the time taken for a unix command?
Use the time
command (details):
time your_prog
If time
does not fit for you, I would try to log the output of date
(details) before and after the execution of your program, e.g.
date > log.txt; your_prog; date >> log.txt
Finally, you can also add some formatting (NOTE: inspired by Raze2dust's answer):
echo "started at: $(date)" > log.txt; your_prog; echo "ended at: $(date)" >> log.txt