If you have a script that runs properly when run from the command line in a shell but will not execute from
cron, you might have a problem with the environment that
cron is running in. Try appending:
To the end of your statement that won't execute in
cron to see what errors are happening during execution. Run the command with
cron and read the contents of the
When I had a problem running
rsync from a
cron file, I received the following output in my
ld.so.1: rsync: fatal: libiconv.so.2: open failed: No such file or directory.
The problem was that the environment wasn't set to find the needed libraries to execute the command. I added an
LD_LIBRARY_PATH environment variable statement to the beginning of my script to set the
LD_LIBRARY_PATH variable to the same value of the one I had in my
.profile file since the script executed properly when I ran it from a shell using my profile.
After that, it worked fine. My
rsync program runs out of
/usr/local/lib so I'm guessing the reference to that area is the one that solved my problem. You could also have other path problems if you don't use the full path when referring to other files in your script.