From owner-freebsd-questions@FreeBSD.ORG Sat Jan 7 14:43:35 2012 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 3B7CB106564A for ; Sat, 7 Jan 2012 14:43:35 +0000 (UTC) (envelope-from kayasaman@gmail.com) Received: from mail-we0-f182.google.com (mail-we0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id B91FD8FC15 for ; Sat, 7 Jan 2012 14:43:34 +0000 (UTC) Received: by werb13 with SMTP id b13so2534174wer.13 for ; Sat, 07 Jan 2012 06:43:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=hCMmiqX0g67SEG+L7QOj/5dZLUl+L5sWQkemR+TuzuA=; b=h0RytjK5+ClFShc7YvnaQykAsVbfj/Cc83T97Epmg+OKR9m5txtVMQaxI+NWFnEF+d tA5RUAZT+hdNaeNgTo+V04KZY1QQcXoIEYvz6F+UxTTH39YkRk9p5tKBKRjrR618c7t5 doSmfSHsLo242zpZbH6Pkik4EyV4KYYA/frPw= Received: by 10.216.132.20 with SMTP id n20mr744351wei.54.1325947413594; Sat, 07 Jan 2012 06:43:33 -0800 (PST) Received: from Hp2230s.localhost (81-178-2-118.dsl.pipex.com. [81.178.2.118]) by mx.google.com with ESMTPS id gf8sm23350590wbb.11.2012.01.07.06.43.31 (version=SSLv3 cipher=OTHER); Sat, 07 Jan 2012 06:43:32 -0800 (PST) Message-ID: <4F085A08.5060502@gmail.com> Date: Sat, 07 Jan 2012 16:43:20 +0200 From: Kaya Saman User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111115 Thunderbird/8.0 MIME-Version: 1.0 To: freebsd-questions@freebsd.org References: <4F0838DF.40006@gmail.com> <20120107132234.31d04a1c@gumby.homeunix.com> <4F084AAD.3050301@gmail.com> <20120107135743.6aa5a6bd@gumby.homeunix.com> <4F0856F6.1060207@infracaninophile.co.uk> In-Reply-To: <4F0856F6.1060207@infracaninophile.co.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: Having problems running shell script from crontab 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: Sat, 07 Jan 2012 14:43:35 -0000 On 01/07/2012 04:30 PM, Matthew Seaman wrote: > On 07/01/2012 13:57, RW wrote: >> On Sat, 07 Jan 2012 15:37:49 +0200 >> Kaya Saman wrote: >> >> n terms of paths this is what I'm doing: I'm in a FreeBSD jail >>> logged in by - #jexec tcsh >>> >>> which gets me in as root. Crontab is being run as root so paths >>> should be the same no? > No -- you can't assume that. The correct thing to do is to set $PATH > within your script, then it should stand a much improved chance of > running correctly irrespective of how it gets started. Add a line like > this near the top of the script: > > export PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin > > That should be good enough for most purposes, but feel free to modify if > needed. > > Another debugging tip: add > > set -x > > or > > set -v -x > > towards the top of the script and you'll get a trace of what the script > does e-mailed to you. (Well, e-mailed to root, but I assume yould've > been reading root's mailbox anyhow, or redirected the root e-mails to > somewhere more useful.) > >> PATH is set at the top of /etc/crontab > Well, yes. However that only helps for the scripts run out of > /etc/crontab. If the OP has done the right thing and left /etc/crontab > alone, but instead set up a root crontab by running > > # crontab -u root -e > > then that wouldn't help at all. > > Cheers, > > Matthew > > Thanks Matthew!!! :-) Exporting the PATH variable was the key, although I did add the debugging tip in for good measure. So luckily all is solved now. Thanks everyone for all the help and advice! Best regards, Kaya