Shell script echo duration

I have a shell script that does a backup job but id like to print the duration of time it took to run

for other systems im able to use this, but it doesnt work on openwrt

#do backup
echo "backup finished in $((duration / 60)) minutes and $((duration % 60)) seconds elapsed."| sendmail -a default

the elapse time is always "0 minutes and 0 seconds elapsed."

used this and it worked

START=$(date +%s);
sleep 1; # Your stuff
END=$(date +%s);
echo $((END-START))

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.