Help needed to add scheduling to a small rc.d script

Miroslav Lachman 000.fbsd at quip.cz
Thu May 29 19:02:16 UTC 2014


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


More information about the freebsd-rc mailing list