From owner-freebsd-questions@FreeBSD.ORG Thu Apr 24 20:43:00 2008 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 CBF451065674 for ; Thu, 24 Apr 2008 20:43:00 +0000 (UTC) (envelope-from cswiger@mac.com) Received: from mail-out4.apple.com (mail-out4.apple.com [17.254.13.23]) by mx1.freebsd.org (Postfix) with ESMTP id B616E8FC16 for ; Thu, 24 Apr 2008 20:43:00 +0000 (UTC) (envelope-from cswiger@mac.com) Received: from relay11.apple.com (relay11.apple.com [17.128.113.48]) by mail-out4.apple.com (Postfix) with ESMTP id 7CA4C2AA4524; Thu, 24 Apr 2008 13:43:00 -0700 (PDT) Received: from relay11.apple.com (unknown [127.0.0.1]) by relay11.apple.com (Symantec Mail Security) with ESMTP id 65AFC28082; Thu, 24 Apr 2008 13:43:00 -0700 (PDT) X-AuditID: 11807130-a8b8ebb000000ead-4a-4810f0d482b7 Received: from cswiger1.apple.com (cswiger1.apple.com [17.214.13.96]) by relay11.apple.com (Apple SCV relay) with ESMTP id 49E702802F; Thu, 24 Apr 2008 13:43:00 -0700 (PDT) Message-Id: From: Chuck Swiger To: John Almberg In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v919.2) Date: Thu, 24 Apr 2008 13:43:00 -0700 References: X-Mailer: Apple Mail (2.919.2) X-Brightmail-Tracker: AAAAAA== Cc: freebsd-questions@freebsd.org Subject: Re: Cron question 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, 24 Apr 2008 20:43:00 -0000 On Apr 24, 2008, at 1:26 PM, John Almberg wrote: > The trouble comes when I try to run this script with cron. I have > something like this in the gs user crontab: > > SHELL=/usr/local/bin/bash > PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/ > local/bin:/usr/X11R6/bin:/home/gs/bin > HOME=/home/gs > 0 15 * * * /home/gs/bin/script.php >>/home/gs/log/script.log > > I can see from the cron log that cron runs script.php at the > appointed hour: > > Apr 24 15:00:03 on /usr/sbin/cron[72414]: (gs) CMD (/home/gs/bin/ > script.php >>/home/gs/log/script.log) I believe that you are going to be better off writing a trivial wrapper like: ----- #! /usr/local/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/ local/bin:/usr/X11R6/bin:/home/gs/bin # ...other env variables you need... touch /home/gs/log/script.log /home/gs/bin/script.php >> /home/gs/log/script.log ----- ...and invoking this wrapper from cron instead of trying to reset the shell and everything from within cron. You can test things by doing an "su gs -c /bin/sh" from a root login and then trying to run your wrapper, which will give you a minimum environment closer to what cron executes under. -- -Chuck