Error when running a script with cron.

Markus Schönhaber ubuntu-users at list-post.mks-mail.de
Tue Jul 12 22:41:26 UTC 2011


13.07.2011 00:02, Wipe_Out:

> I have written a basic bash script to stop and restart xinetd as part of a
> cleanup routine for a server we run.. When run from a prompt it runs
> perfectly.. I have scheduled it to run every night as a cron job and every
> night I get an email with the following error..
> 
> /etc/init.d/xinetd: 75: start-stop-daemon: not found
> /etc/init.d/xinetd: 75: start-stop-daemon: not found
> 
> I can't figure out why..
> 
> Can anyone give me any ideas??

Yes. The environment of a script run by cron is much different of the
environment of a script run from the prompt. Especially, by default,
cron sets
PATH=/usr/bin:/bin
but start-stop-deamon sits in /sbin.

So, in your script, you'll have to explicitly set PATH the way you need it.

-- 
Regards
  mks




More information about the ubuntu-users mailing list