James,

> Searching for "works from command line but not via cron" shows that you're
> not alone :)
> Usually, this stems from the fact that cron doesn't execute your various
> shell initialisation scripts - ~/.profile, ~/.bashrc, ~/.bash_profile,
> ~/.login, etc. A common problem is thus that $PATH isn't set (when the
> script runs under cron) to what you expect (based on what you see when
> you're running it by hand). However, all sorts of other things could be
> different: your ~/.bash_profile might set a non-standard umask; or set up
> some aliases that don't exist when the script runs under cron.
> 
Nothing non standard about my bash profile but on this system, both root
and my own bash profiles are identical.

> Changing the shebang line to "#!/bin/sh -x" will cause each line to be
> echoed; if you then change the cronjob to ">>/var/log/cronlog" or similar
> you should get some more information about what cron is actually running,
> and what the rsync commands are doing.
> 

I will add the logging.

> A random guesses, aside from the things I've mentioned above: the shebang
> line stipulates /bin/sh; I'd bet you're not using /bin/sh as your shell. On
> some systems /bin/sh is bash; on other systems it's something different -
> maybe sh, maybe dash, maybe bash-in-sh-compatibility-mode.
> 
I hoping that the shebang line is the problem although that does not
explain why it runs on the CLI as root and not fully as root in cron.  I
have changed it to bash but won't know until tomorrow morning if it is
going to behave.

> Another random guess: if the cronjob runs as a user who doesn't have
> 192.168.0.20 in their ~/.ssh/known_hosts file, ssh will ask questions about
> whether you really want to connect. It's possible that when you do it by
> hand you have a pre-populated ~/.ssh/known_hosts, but the cronjob runs as a
> different user and doesn't have that.
> 
No - that's not the issue.  192.168.0.20 is included in root's known
hosts.

Thanks for giving me some places to look.

Rick

-- 
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html

Reply via email to