From owner-freebsd-questions@FreeBSD.ORG Fri Mar 26 02:47:01 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 7D44116A4CF for ; Fri, 26 Mar 2004 02:47:01 -0800 (PST) Received: from mail.u4eatech.com (blackhole.u4eatech.com [195.188.241.2]) by mx1.FreeBSD.org (Postfix) with ESMTP id 56EC043D3F for ; Fri, 26 Mar 2004 02:47:00 -0800 (PST) (envelope-from richard.williamson@u4eatech.com) Received: (from filter@localhost) by mail.u4eatech.com (8.11.6/8.11.6) id i2QAkxc16227 for freebsd-questions@freebsd.org; Fri, 26 Mar 2004 10:46:59 GMT X-Authentication-Warning: mail.u4eatech.com: filter set sender to richard.williamson@u4eatech.com using -f Received: from apus.u4eatech.com (unknown [172.30.20.100]) by mail.u4eatech.com (Postfix) with ESMTP id 5591A1577D4 for ; Fri, 26 Mar 2004 10:46:53 +0000 (GMT) Message-Id: <6.0.3.0.2.20040326103618.025871c0@cygnus> X-Sender: richard@cygnus X-Mailer: QUALCOMM Windows Eudora Version 6.0.3.0 Date: Fri, 26 Mar 2004 10:50:06 +0000 To: freebsd-questions@freebsd.org From: "Richard P. Williamson" Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, hits=-5.4 required=5.0 tests=BAYES_01 version=2.55 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp) Subject: 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 10:47:01 -0000 Hello world, I've got a shell script that in essence does this: FOREVER: pre-process stuff mainapp post-process stuff If the mainapp returns too soon, the assumption must be that there is a configuration problem of some sort. Under those conditions, I don't want to immediately jump to the pre-process stuff and start the mainapp again. Instead, I want to sleep for an arbitrary time between attempts (giving an operator some leeway to fix the configuration before trying again). If mainapp runs long enough, then it should just post-, pre- mainapp again immediately. 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. rip