I often find myself wanting to write shell scripts that do: while : do {report some statistic} sleep 10 done now this is of course only approximate as the delay will not be exactly 10 seconds and it will gradually creep.. This doesn't matter too much except that I now need to do the same on 50 machines and I need the data to line up. The machiens all have ntp running so their clocks are all alligned (enough) so what I really need is: while: do report results sleep -until_next 10 done I have inplemented something like this with a crude shell function that sleeps up to 9 seconds to get to thenext N+9 second, and then loops with sleep 0.1 up to 10 times until the second ticks over, but that is a hack and inneficient to say the least.. firstly: does anyone know a better way to do this? secondly: is it worth implementing some "do ths every N seconds" facility somewhere? e.g. sleep -u 10 # sleep until next 10 second boundary. thirdly: is it worth making sleep a shell builtin? running sleep(1) every time is a lot of work for what we need. julianReceived on Tue Feb 01 2005 - 17:20:28 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:27 UTC