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

#!/bin/bash
SECONDS=0
#do backup
duration=$SECONDS
echo "backup finished in $((duration / 60)) minutes and $((duration % 60)) seconds elapsed."| sendmail -a default og@hotmail.com

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))

https://manpages.debian.org/bookworm/time/time.1.en.html

1 Like

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