From owner-freebsd-questions@FreeBSD.ORG Thu Aug 30 01:32:13 2007 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8643016A417 for ; Thu, 30 Aug 2007 01:32:13 +0000 (UTC) (envelope-from mnslinky@gmail.com) Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.183]) by mx1.freebsd.org (Postfix) with ESMTP id 1D27413C468 for ; Thu, 30 Aug 2007 01:32:12 +0000 (UTC) (envelope-from mnslinky@gmail.com) Received: by py-out-1112.google.com with SMTP id u77so2660535pyb for ; Wed, 29 Aug 2007 18:32:12 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:in-reply-to:references:mime-version:x-priority:content-type:message-id:cc:content-transfer-encoding:from:subject:date:to:x-mailer; b=EUNG0USKcy0kdsrUYTN0gYml6PakCApuB7251YDswZtY41QDE3JqxFrNh8hiPj1oZf8lfgeRVGlzNSfitcPr9v3hnc7vCqHN6ZnPuGzkmSQByIb1wljwLruKGqkSFcPGPnK8AwOiamAXUJQMQRDkyaL+38k3/KeRkfyRK8TlGcs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:in-reply-to:references:mime-version:x-priority:content-type:message-id:cc:content-transfer-encoding:from:subject:date:to:x-mailer; b=RqJtFh4kxj0y1uEeOReHe05PV0KCogbpURuZQmorjHtw9damds6H07vlXWK+BdTHhME1ekgEC8q/Ta4Rmdb11BOntPUssOAT+vhAI4z9OvrqTZUdTj7aVb1EB5yxL+RZFUJaWUfUb0dqFwh14l6eRM+WrB628aN6YvkiWdijCck= Received: by 10.35.12.10 with SMTP id p10mr1506681pyi.1188437531687; Wed, 29 Aug 2007 18:32:11 -0700 (PDT) Received: from ?192.168.1.3? ( [209.240.66.157]) by mx.google.com with ESMTPS id n44sm10455575pyh.2007.08.29.18.32.10 (version=SSLv3 cipher=OTHER); Wed, 29 Aug 2007 18:32:10 -0700 (PDT) In-Reply-To: <01db01c7ea79$87b1d730$1e00a8c0@cheqsoft.local> References: <01a901c7ea3d$0ad62720$1e00a8c0@cheqsoft.local> <01cd01c7ea71$2aa3cb50$1e00a8c0@cheqsoft.local> <35135D25-B5FC-410E-BBAF-DADE4F24085B@gmail.com> <01db01c7ea79$87b1d730$1e00a8c0@cheqsoft.local> Mime-Version: 1.0 (Apple Message framework v752.3) X-Priority: 3 Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <4BABEDD3-26CC-4051-A422-973F6A4F37FD@gmail.com> Content-Transfer-Encoding: 7bit From: Eric Crist Date: Wed, 29 Aug 2007 20:31:58 -0500 To: Hinkie X-Mailer: Apple Mail (2.752.3) Cc: freebsd-questions@FreeBSD.ORG Subject: Re: FreeBSD Cron Job to run (ifconfig em0 down; ifconfig em0 up) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Aug 2007 01:32:13 -0000 David, you can also run it on a single line by piping it into sh: /bin/sh | command here However, feel free to put it in a file. Somethings as simple as this I like to make one-liners so they're easy to read in the crontab entry. Glad I could help! Eric On Aug 29, 2007, at 3:16 PMAug 29, 2007, Hinkie wrote: > 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" > To: "Hinkie" > Cc: > 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 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" >> To: "Hinkie" >> Cc: >> 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 > ----- Eric F Crist Secure Computing Networks