Thanks, Jim!
I created the script /usr/bin/env and ran it manually and in crontab
.
The PATH variable in the manually-run output file is long. The PATH variable in the file run in crontab is short - PATH=/usr/bin:/bin. So, thinking I needed to tell cron to use the long PATH variable, I added it into the script: (PATH=/opt/CPsuite-R77/...), but that didn't work when I ran the job from crontab.
Thanks for the response, Don.
"Look at the threads at the bottom of this page. There are five threads there with exactly the same problem you are having and the same suggestions we have been making here solved the problem for all of them."
If that were true, I'd have figured it out by now. The problems in the other threads are "similar", but not "exactly the same". I read through them before I posted my issue. Had I been able to solve my problem using suggestions posted in the other threads, I wouldn't have posted mine.
I get that my problem probably has to do with setting the environment variables, but it's not clear to me yet how to do that.
"When you run the program manually and it works, what shell are you using? Change the 1st line of your script from:
shell=/bin/bash
to:
#!pathname
where pathname is the absolute pathname of the shell you are using. Does that change make your script work when run by cron ?"
Since the first line in the script is shell=bin/bash, I'm using the bash shell, right? Changed the first line to #!/bin/bash. Still doesn't work using cron.
I'm running the job from my home directory -
/home/admin
"? Add a command to your script before you invoke
/opt/CPsuite-R77/fw1/bin/upgrade_tools/upgrade_export
that changes your current working directory in your script to that directory:
cd directory
where directory is the string returned by the above pwd command. After that change, does your script work when run by cron ?"
Still doesn't work.
"When you run the program manually and it works, what environment variables does your program need to run correctly? Does your program work correctly if you invoke it manually with the commands:"
today=$(date +"%m-%d-%y")
env - PATH="/bin:/usr/bin" /opt/CPsuite-R77/fw1/bin/upgrade_tools/upgrade_export mgt-svr-bkup-$today << EOF
y
n
EOF
Yes.