Date: Thu, 24 Apr 2008 13:43:00 -0700 From: Chuck Swiger <cswiger@mac.com> To: John Almberg <jalmberg@identry.com> Cc: freebsd-questions@freebsd.org Subject: Re: Cron question Message-ID: <DA3E6BB8-7E09-4EDB-9E79-A7FE8832734F@mac.com> In-Reply-To: <C615711F-BD11-4AAE-8321-5A93A64863E6@identry.com> References: <C615711F-BD11-4AAE-8321-5A93A64863E6@identry.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?DA3E6BB8-7E09-4EDB-9E79-A7FE8832734F>