<div dir="ltr">In a bash script you could use something like:<div><br></div><div><font face="monospace">time (</font></div><div><span style="font-family:monospace">    echo "Hello World"</span></div><div><font face="monospace">    find .<br>    echo "Done"<br></font></div><div><font face="monospace">)</font></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 3 Jan 2024 at 11:40, William Kenworthy <<a href="mailto:bill@kenworthy.id.au">bill@kenworthy.id.au</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The time utility might give you options?<br>
<br>
"man time"<br>
<br>
BillK<br>
<br>
<br>
On 3/1/24 11:04, Brad Campbell wrote:<br>
> G'day mobsters..<br>
><br>
> Quite often I find myself wanting to time tasks in scripts. I used to use all sorts of if/then maths to break up seconds to clock friendly formats.<br>
> I had a thought perhaps I could make date do it for me. Turns out the Epoch was a Thursday, so we need to fast forward 3 days to get a workable day count (start on day 0).<br>
><br>
> This gives elapsed time in days:hours:minutes:seconds. However it only works for tasks that run less than 7 days or the day counter wraps.<br>
><br>
> START=`date +%s`<br>
><br>
> // insert task here<br>
><br>
> END=`date +%s`<br>
> echo Task took `date -d @$((END-START+259200)) -u +%w:%H:%M:%S`<br>
><br>
> Just to point out another ugly, ugly bruteforce way I've used in the past :<br>
><br>
> # ------------ How long did the task take? ---------------<br>
> END=`date +%s`<br>
> runtime=$(($END-$START))<br>
> let days=$(($runtime/86400))<br>
> let hrt=$(($runtime%86400))<br>
> let hours=$(($hrt/3600))<br>
> let mint=$(($hrt%3600))<br>
> let minutes=$(($mint/60))<br>
> let secsd=$((mint%60))<br>
> echo Task took `printf "%.2d:%.2d:%.2d:%.2d" $days $hours $minutes $secsd`<br>
><br>
> A couple of the many, many ways to skin a cat. I like the former method, but I'm always interested to see alternatives.<br>
><br>
> Regards,<br>
> Brad<br>
> _______________________________________________<br>
> PLUG discussion list: <a href="mailto:plug@plug.org.au" target="_blank">plug@plug.org.au</a><br>
> <a href="http://lists.plug.org.au/mailman/listinfo/plug" rel="noreferrer" target="_blank">http://lists.plug.org.au/mailman/listinfo/plug</a><br>
> Committee e-mail: <a href="mailto:committee@plug.org.au" target="_blank">committee@plug.org.au</a><br>
> PLUG Membership: <a href="http://www.plug.org.au/membership" rel="noreferrer" target="_blank">http://www.plug.org.au/membership</a><br>
><br>
><br>
_______________________________________________<br>
PLUG discussion list: <a href="mailto:plug@plug.org.au" target="_blank">plug@plug.org.au</a><br>
<a href="http://lists.plug.org.au/mailman/listinfo/plug" rel="noreferrer" target="_blank">http://lists.plug.org.au/mailman/listinfo/plug</a><br>
Committee e-mail: <a href="mailto:committee@plug.org.au" target="_blank">committee@plug.org.au</a><br>
PLUG Membership: <a href="http://www.plug.org.au/membership" rel="noreferrer" target="_blank">http://www.plug.org.au/membership</a><br>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr">Onno Benschop<br><br>()/)/)()        ..ASCII for Onno..<br>|>>?            ..EBCDIC for Onno..<br>--- -. -. ---   ..Morse for Onno..<br><br><span style="color:rgb(136,136,136)">If you need to know: "What computer should I buy?" </span><a href="http://goo.gl/spsb66" style="color:rgb(17,85,204)" target="_blank">http://goo.gl/spsb66</a><div><br>ITmaze   -   ABN: 56 178 057 063   -  ph: 04 1219 8888   -   <a href="mailto:onno@itmaze.com.au" target="_blank">onno@itmaze.com.au</a></div></div></div>