From owner-freebsd-questions@FreeBSD.ORG Thu Sep 18 03:49:56 2003 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 27B4B16A4B3 for ; Thu, 18 Sep 2003 03:49:56 -0700 (PDT) Received: from remt26.cluster1.charter.net (remt26.cluster1.charter.net [209.225.8.36]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9967D43FDD for ; Thu, 18 Sep 2003 03:49:54 -0700 (PDT) (envelope-from chowse@charter.net) Received: from [66.168.145.25] (HELO moe) by remt26.cluster1.charter.net (CommuniGate Pro SMTP 4.0.6) with ESMTP id 159967673; Thu, 18 Sep 2003 06:49:53 -0400 From: "Charles Howse" To: "'Rob Lahaye'" , "'Gil Agno Virtucio'" , Date: Thu, 18 Sep 2003 05:49:47 -0500 Message-ID: <001701c37dd2$9467f170$04fea8c0@moe> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2616 In-Reply-To: <3F697722.3000302@snu.ac.kr> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Importance: Normal Subject: RE: randomize execution the a script? 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: Thu, 18 Sep 2003 10:49:56 -0000 > Gil Agno Virtucio wrote: > > Hi. I want to randomize the execution of a shell script.=20 > Can i use cron=20 > > to do this? or are there other available tools that i can=20 > use to do this? >=20 > See 'man 6 random' and 'man sleep'. > Then try doing something like this in the background: >=20 > #!/bin/sh > while true > do > random -e 60 > randomNumber=3D$? > sleep $randomNumber > > done >=20 > Where '60' means, maximum 60 seconds between two script calls. >=20 > There might be better or nices ways of doing this :). I don't happen to have random installed on my system, however jot is installed with the base system, and will generate random numbers quite well. For example 'jot -r 1 1 60' will generate a single random number between 1 and 60. Won't randomNumber=3D$? Just return 0 if the previous command completes successfully? Shouldn't it be: randomNumber=3D`random -e 60` Or better yet randomNumber=3D`jot -r 1 1 60`