Executing an script with crontab returns 127 error code
Question
I am executing a script manually on my UNIX system manually, it runs successfully and updated required records in ORACLE database. How ever when I exwcute the same script with crontab my process exits with the error code 127.
On analysing further, I got there is some problem in these statements.
LOGFILE=sachin ORALOGIN=abc/abc@abcd
cmd='sqlplus ${ORALOGIN} < SQLS >> ${SVC_HOME}/LOGFILES/${LOGFILE}.date +%Y-%m-%d
';
eval $cmd
Please suggest a solution
Solution
Are you sure that ${ORALOGIN}
and ${LOGFILE}
are valid ENV variables when cron executes the script?
Sometimes scripts that work for users don't work for cron because cron executions don't have all the ENV variables that users have.
OTHER TIPS
In the interactive enviroment do
env | grep ORACLE
Long time since I've used sqlplus, but I recall it required some environment variables to function (ORACLE_HOME?) and I'm suspecting your cron job environment does not have these set.