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

_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to