From owner-freebsd-rc@FreeBSD.ORG Thu May 29 19:02:16 2014 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id AF749B8E for ; Thu, 29 May 2014 19:02:16 +0000 (UTC) Received: from elsa.codelab.cz (elsa.codelab.cz [94.124.105.4]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 6BB632CD1 for ; Thu, 29 May 2014 19:02:16 +0000 (UTC) Received: from elsa.codelab.cz (localhost [127.0.0.1]) by elsa.codelab.cz (Postfix) with ESMTP id 920502842C; Thu, 29 May 2014 20:53:06 +0200 (CEST) Received: from [192.168.1.2] (ip-89-177-49-222.net.upcbroadband.cz [89.177.49.222]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by elsa.codelab.cz (Postfix) with ESMTPSA id 75ACA28429; Thu, 29 May 2014 20:53:05 +0200 (CEST) Message-ID: <53878210.3010406@quip.cz> Date: Thu, 29 May 2014 20:53:04 +0200 From: Miroslav Lachman <000.fbsd@quip.cz> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.9.1.19) Gecko/20110420 Lightning/1.0b1 SeaMonkey/2.0.14 MIME-Version: 1.0 To: Pietro Sammarco Subject: Re: Help needed to add scheduling to a small rc.d script References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-rc@freebsd.org X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 May 2014 19:02:16 -0000 Pietro Sammarco wrote: [...] > Essentially what I need to do is to add a 30 seconds scheduling time to > this script, so that each and every 30 seconds it will check if > google.comis pingable, and if not it will do what the script it > supposed to do, and > at the same time I want to keep the start and stop feature. You can use endless loop with sleep 30 in it. while [ 1 ]; do if ! [ `ping -q -c 4 -o google.com > /dev/null` ]; then ifconfig wlan0 down & ifconfig wlan0 up & dhclient wlan0 fi sleep 30 done It is better to send more than one packet in case of some packet loss on the line (-c 4) The problem with your rc script is, that it will be running forever and will not return. I think you need one script running like a "daemon" and another one (rc) to control the first one. (starting / stopping) You can learn more about rc scripting in this article http://www.freebsd.org/doc/en/articles/rc-scripting/article.html Miroslav Lachman