From owner-freebsd-questions Sun Nov 24 14:54: 7 2002 Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F230D37B401 for ; Sun, 24 Nov 2002 14:54:05 -0800 (PST) Received: from mgw1-out.MEIway.com (mgw1.meiway.com [212.73.210.75]) by mx1.FreeBSD.org (Postfix) with ESMTP id 94A7C43E6E for ; Sun, 24 Nov 2002 14:54:04 -0800 (PST) (envelope-from LConrad@Go2France.com) Received: from VirusGate.MEIway.com (virus-gate.meiway.com [212.73.210.91]) by mgw1-out.MEIway.com (Postfix Relay Hub) with ESMTP id B2FF0EF6A6 for ; Sun, 24 Nov 2002 23:53:53 +0100 (CET) Received: from localhost (localhost.meiway.com [127.0.0.1]) by VirusGate.MEIway.com (Postfix) with SMTP id AFCAC5D009 for ; Sun, 24 Nov 2002 23:54:01 +0100 (CET) Received: from mail.Go2France.com (ms1.meiway.com [212.73.210.73]) by VirusGate.MEIway.com (Postfix) with ESMTP id 3F99D5D008 for ; Sun, 24 Nov 2002 23:54:01 +0100 (CET) Received: from tx0-go2france-c.Go2France.com [193.252.44.38] by mail.Go2France.com with ESMTP (SMTPD32-6.06) id AB0A945401B0; Mon, 25 Nov 2002 00:04:42 +0100 Message-Id: <5.1.1.6.2.20021124234729.02d7a030@mail.go2france.com> X-Sender: LConrad@Go2France.com@mail.go2france.com X-Mailer: QUALCOMM Windows Eudora Version 5.1.1 Date: Sun, 24 Nov 2002 23:53:51 +0100 To: freebsd-questions@freebsd.org From: Len Conrad Subject: Re: .sh interactive ok, from crontab, not In-Reply-To: References: <5.1.1.6.2.20021124194251.02c390c0@mail.go2france.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > > if ( ps aux | grep -i "^root.*master" ) > /dev/null > > then > > echo "then: exit code equal 0" > > exit 0 > > else > > > > > > ... when run from the command line, the echo text displays. But, when run > > from crontab every 10 minutes, the if fails, and the else clause runs. > > > > I've tried every syntax I know, but still can't get this logic to work. > >It works for me, and I suspect that it's working for you, too. well, it's really not. The crontab execution is trying to run the daemon even when the daemon shows up in "ps aux". > However, you >may not see the results expected if you are piping the cron output through >sendmail I'm not, and anyway the echo is after the IF condition "fails". >Also, make sure that you're running the expected shell. Check the SHELL= >line in crontab, or force the script to run via the expected shell by >running 'sh script' instead of just 'script', or tell the script what shell >to run by adding something like the following on the first line: > >#!/bin/sh already there, and /etc/crontab also contains SHELL=/bin/sh >Although this isn't related to your problem , you might find it simpler to >use the -q option on grep instead of redirecting the output. For example, > >if ( ps -aux | grep -q -i "^root.*master" ); then > >instead of, ok. thanks Len To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message