From owner-freebsd-current@FreeBSD.ORG Tue Feb 1 18:20:28 2005 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3266116A4CE for ; Tue, 1 Feb 2005 18:20:28 +0000 (GMT) Received: from pimout3-ext.prodigy.net (pimout3-ext.prodigy.net [207.115.63.102]) by mx1.FreeBSD.org (Postfix) with ESMTP id CD31343D1D for ; Tue, 1 Feb 2005 18:20:27 +0000 (GMT) (envelope-from julian@elischer.org) Received: from [192.168.1.102] (adsl-216-100-134-143.dsl.snfc21.pacbell.net [216.100.134.143])j11IKPoC277694 for ; Tue, 1 Feb 2005 13:20:26 -0500 Date: Tue, 1 Feb 2005 10:20:24 -0800 (PST) From: Julian Elischer X-X-Sender: julian@localhost To: current@freebsd.org Message-ID: <20050201101113.J572@localhost> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Subject: cynchronised sleep capbilty.. X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Feb 2005 18:20:28 -0000 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. julian