What is "fails"? Do you get an error message? Just no results?
With zero information to go on, I'd say look at your environment variables. Be sure everything is set up in the process so that it can connect correctly. Be sure 'ssh' is in the PATH or specify an absolute path to SSH in you script. Be sure the current working directory is set up correctly. chdir("/tmp") if you have to, if the script is writing files to the current directory.
In short, check your assumptions. The environment the script is running under via cron won't be the same as what it is running under a shell prompt. Be sure everything is set up correctly. Add debugging code to your script so that it explains what it's trying to do and where it's trying to do it. Check for errors with your various functions that return errors and print those errors out so that you can see where your script is failing.
Aside from these general tips, it's nearly impossible for us to help you without additional information. Good luck. | [reply] [d/l] |
If, when you manually ssh to those other machines, you have
to type in a password, cron is going to throw up because it
isn't set up to give that kind of input. There are ways
you can set up ssh to not need to supply a password (RSA
keys or something, I don't know for sure, go read some man
pages or websites).
Of course, you could write a wrapping script in
Expect1 to take care of that pesky problem,
but that's probably Not The Way To Go.
1 Yes, I know I will burn in hell (and get
downvotes) for mentioning another language here, but this
kind of tty-needing, input-needing interaction is just
what Expect is for. | [reply] |
cron scripts often fail due to a reliance on the tty. Watch
out for user input or output.
Other than that, it could be anything. More info about
the nature of the failure is required here.
--
Brother Marvell | [reply] |