Bash script to calculate time elapsed

后端 未结 10 1464
被撕碎了的回忆
被撕碎了的回忆 2021-01-29 22:03

I am writing a script in bash to calculate the time elapsed for the execution of my commands, consider:

STARTTIME=$(date +%s)
#command block that takes time to c         


        
10条回答
  •  闹比i
    闹比i (楼主)
    2021-01-29 22:19

    I find it very clean to use the internal variable "$SECONDS"

    SECONDS=0 ; sleep 10 ; echo $SECONDS

提交回复
热议问题