Quantcast
Channel: shell script – PCtechtips.org
Viewing all articles
Browse latest Browse all 17

Calculating Execution Time for a Bash Script

$
0
0
Sometimes you want to know how long the script takes to execute. Here are the basic steps… 1-Get the starting time 2-Get the end time 3-Subtract (endTime – startTime). startTime=$(date +%s) ##### code here ########## endTime=$(date +%s) diff=$((endTime - startTime)) echo "Elapse time is $((diff/60)) minutes and $((diff%60)) seconds"

Viewing all articles
Browse latest Browse all 17

Trending Articles