Hi there,
Now I'm facing error regarding running shell script via cron.
The shell script which is required to get value from database.
Below is the main part of shell script.
#/bin/bash
#connect to database(1)
db2 connect to $database user xxxx using yyyy
#set values from database(2)
status=`db2 -x select status from TABLE_X where end_date = select max(end_date) from TABLE_X`
#rest of the process(3)
if [ ${status} -eq 2 ]; then
echo 'SUCCESS'
process to next step
elif [ ${status} -eq 1 ]; then
'WARNING'
exit 2
else
echo 'FATAL'
exit 99
fi
process (1) success, but process (2) doesn't work when run this script via cron, so process (3) always exit with FATAL.
It works properly when run this manually.
I try some solutions:
- edit crontab settings
(before)
*/10 * * * * /home/aaa/bbb/PPAP.sh
(after)
*/10 * * * * /bin/bash -l /home/aaa/bbb/PPAP.sh
- run db2profile in shell script
I reffered the relate topic and try that, but error still exists...
ttp://dba.stackexchange.com/questions/91807/online-backup-is-not-performed-from-the-cron-job-on-linux-server-manually-it-wo
Somebody has idea??
Thank you in advance.