problems with init.d script via cron

Bill Campbell linux-sxs
Mon Aug 23 16:38:14 PDT 2004


On Mon, Aug 23, 2004, Jason Joines wrote:
>	I have an init.d script that works fine interactively.  That is I 
>	can use it to start, stop, restart, etc., the service via 
>	"/etc/init.d/scriptname arguments" from a command prompt.  However, 
>	it fails when run from cron.
>
>	It has these variables and start line:
>CONFIGDIR=/etc/rembo
>CONFIGFILE=rembo.conf
>BINDIR=/opt/rembo
>BINFILE=rembo
>startproc $BINDIR/$BINFILE -v 4 -c $CONFIGDIR/$CONFIGFILE
>
>	I need to have cron restart this service nightly after some files 
>	are updated.  When I try to have cron do it the start line generates 
>	this error:
>cannot stat `/etc/rembo/.conf': No such file or directory
>
>	Looks like it's dropping the part between the front slash and the 
>	period.  I've tried all sorts of quotations and such but no luck so 
>	far.  Any ideas how to make this behave?

This type of problem is almost always due to missing environment variables
that are set in the shell, but not in the cron environment.

You may be able to identify the problem by comparing the shell
environment with the cron environment.  At the shell prompt
enter ``env | sort > /tmp/env.shell'', then add a line at the
beginning of the cron script ``env | sort > /tmp/env.cron'', and
finally compare the /tmp/env.shell and /tmp/env.cron files to see
what's missing from /tmp/env.cron.

Bill
--
INTERNET:   bill at Celestial.COM  Bill Campbell; Celestial Software LLC
UUCP:               camco!bill  PO Box 820; 6641 E. Mercer Way
FAX:            (206) 232-9186  Mercer Island, WA 98040-0820; (206) 236-1676
URL: http://www.celestial.com/

``Guns are no more responsible for killing people than the spoon is
responsible for making Rosie O'Donnell fat.''


More information about the Linux-users mailing list