Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 Aug 2007 08:16:48 +1200
From:      Hinkie <Hinkie@paradise.net.nz>
To:        Eric Crist <mnslinky@gmail.com>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: FreeBSD Cron Job to run (ifconfig em0 down; ifconfig em0 up)
Message-ID:  <01db01c7ea79$87b1d730$1e00a8c0@cheqsoft.local>
References:  <01a901c7ea3d$0ad62720$1e00a8c0@cheqsoft.local> <FD866B42-B6DA-4AC1-A4B0-EC858835CEBE@gmail.com> <01cd01c7ea71$2aa3cb50$1e00a8c0@cheqsoft.local> <35135D25-B5FC-410E-BBAF-DADE4F24085B@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Eric

You are of course correct, it runs under "sh"

I think that means I have to run it in a separate script file

I write it as (First_Hop subs with a.b.c.1)

#!/bin/sh
if ! ping -c1 First_Hop >/dev/null 2>/dev/null
   then 
        echo First_Hop_OK
   else
        ifconfig em0 down && ifconfig em0 up
        echo Restored
fi

Save as /etc/pinger.sh

Try run:

pfsense-p266ii:~#  /etc/pinger.sh
/etc/pinger.sh: Permission denied.

Try fix:

pfsense-p266ii:~#  chmod 777 /etc/pinger.sh
chmod: /etc/pinger.sh: Read-only file system

Hmmmm  I assume if it won't run here then crontab won't run it either?

Kind regards 
David Hingston

----- Original Message ----- 
From: "Eric Crist" <mnslinky@gmail.com>
To: "Hinkie" <Hinkie@paradise.net.nz>
Cc: <freebsd-questions@FreeBSD.ORG>
Sent: Thursday, August 30, 2007 7:30 AM
Subject: Re: FreeBSD Cron Job to run (ifconfig em0 down; ifconfig em0 up)


David,

The script I provided assumes the sh shell.  Most shell scripts have  
been historically written for the bourne shell.  Before running the  
script I sent you, try typing sh<enter> at the command line.  Then,  
run the line I sent your way.

Let me know how it works for you!

Eric


On Aug 29, 2007, at 2:16 PMAug 29, 2007, Hinkie wrote:

> Hi Eric
>
> Thank you for that, I think I see one thing I was doing wrong  
> (putting the ping into the if!)
>
> Running your code in the command window I get (Following the  
> successful ping)
>
> TESTV=0: Command not found.
> TESTV: Undefined variable.
>
> As you can tell I am learning this syntax!
>
> Can you help me further?
>
> With thanks
>
> David Hingston
>
> ----- Original Message -----
> From: "Eric Crist" <mnslinky@gmail.com>
> To: "Hinkie" <Hinkie@paradise.net.nz>
> Cc: <freebsd-questions@FreeBSD.ORG>
> Sent: Thursday, August 30, 2007 2:17 AM
> Subject: Re: FreeBSD Cron Job to run (ifconfig em0 down; ifconfig  
> em0 up)
>
>
> On Aug 29, 2007, at 8:03 AMAug 29, 2007, Hinkie wrote:
>
>> Hi
>>
>> I want to run a cron job in /etc/crontab that runs (ifconfig em0
>> down; ifconfig em0 up) if my cables static ip gateway can't be
>> pinged but I can't figure it out.  I can't get the syntax that runs
>> in the command window, to then put intot the crontab....
>>
>> Can anyone help me?
>
> Here's what I'd use:
>
> ping -c 1 a.b.c.d; TESTV=$?; if [ $TESTV != 0 ]; then `ifconfig em0
> down`; fi
>
> HTH
> -----
> Eric F Crist
> Secure Computing Networks
>
> _______________________________________________
> freebsd-questions@freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions- 
> unsubscribe@freebsd.org"

-----
Eric F Crist
Secure Computing Networks




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?01db01c7ea79$87b1d730$1e00a8c0>