Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 May 2014 20:53:04 +0200
From:      Miroslav Lachman <000.fbsd@quip.cz>
To:        Pietro Sammarco <pietro.bsdml@gmail.com>
Cc:        freebsd-rc@freebsd.org
Subject:   Re: Help needed to add scheduling to a small rc.d script
Message-ID:  <53878210.3010406@quip.cz>
In-Reply-To: <CA%2B7eH3XGh5yfr8eFL3oDMM4cZRVvNJF48K89p-ek5co22VF0ig@mail.gmail.com>
References:  <CA%2B7eH3XGh5yfr8eFL3oDMM4cZRVvNJF48K89p-ek5co22VF0ig@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53878210.3010406>