From owner-freebsd-questions@FreeBSD.ORG Fri Mar 26 05:10:47 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5986D16A5D4 for ; Fri, 26 Mar 2004 05:10:47 -0800 (PST) Received: from dire.bris.ac.uk (dire.bris.ac.uk [137.222.10.60]) by mx1.FreeBSD.org (Postfix) with ESMTP id BFD7243D39 for ; Fri, 26 Mar 2004 05:10:46 -0800 (PST) (envelope-from Jan.Grant@bristol.ac.uk) Received: from mail.ilrt.bris.ac.uk by dire.bris.ac.uk with SMTP-PRIV with ESMTP; Fri, 26 Mar 2004 13:09:33 +0000 Received: from cmjg (helo=localhost) by mail.ilrt.bris.ac.uk with local-esmtp (Exim 3.16 #1) id 1B6r4w-0003qn-00; Fri, 26 Mar 2004 13:08:54 +0000 Date: Fri, 26 Mar 2004 13:08:54 +0000 (GMT) From: Jan Grant X-X-Sender: cmjg@mail.ilrt.bris.ac.uk To: "Richard P. Williamson" In-Reply-To: <6.0.3.0.2.20040326103618.025871c0@cygnus> Message-ID: References: <6.0.3.0.2.20040326103618.025871c0@cygnus> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: Jan Grant cc: freebsd-questions@freebsd.org Subject: Re: sleeping for 30 seconds X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Mar 2004 13:10:47 -0000 On Fri, 26 Mar 2004, Richard P. Williamson wrote: > What's a good sh algorithm for the above? (assume < 10 > seconds indicates error condition and a 50 second sleep > between iterations when necessary, and I don't need a > 'five attempts then sleep' thing). Also, assume I've > simplified for the home audience. The sh script is > lots more involved then the example above implies. You might, if the possibility is there, want to use the exit value of the main process to indicate errors, which is perhaps a little more reliable. If you want the time in seconds between two points, you might try something like this: start_time=`date +%s` # ... do something end_time=`date +%s` time_taken=$(($end_time - $start_time)) -- jan grant, ILRT, University of Bristol. http://www.ilrt.bris.ac.uk/ Tel +44(0)117 9287088 Fax +44 (0)117 9287112 http://ioctl.org/jan/ New Freedom of Information Act: theirs, to yours. Happy now?