I have bash script and I put in the crontab. It runs every 10 minutes. When I run it manually, it gives perfect results. It creates “.tmp” files and these “.tmp” files are not empty, but Crontab results are not as I expected. it only creates “.tmp” files. Contents of “.tmp” files are empty. In this computer there more than one user. Could it be user privilege issue? What could be the main reason?
Thanks in advance..
Sorry, I forgot 🙂 my code.
export GGATE=/ggate/ggs11g
alias gate='clear;cd $GGATE;./ggsci'
export ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/dbhome_1
export ORACLE_SID=KNNPRO17_1
export PATH=$PATH:$ORACLE_HOME/bin:$LD_LIBRARY_PATH:${GGS_HOME}
export LIBPATH=$ORACLE_HOME/lib:$GGS_HOME:$PATH
export LD_LIBRARY_PATH=$PATH:$ORACLE_HOME:$ORACLE_HOME/lib:$GGS_HOME
MYGGSCI=$GGATE/ggsci
LOGDIR=$GGATE/scripts/logs
GGSLAGFILE01=${LOGDIR}/ggslagfile01.tmp
GGSLAGFILE02=${LOGDIR}/ggslagfile02.tmp
GGSLAG_EMAIL=${LOGDIR}/ggslag_email.tmp
$MYGGSCI << eof > $GGSLAGFILE01
info all
eof
cat $GGSLAGFILE01 | egrep -i '(EXTRACT)'|cut -d":" -f 1,2,3,4,5,6 | tr ":" " "|tr -s '[:space:]'|cut -d" " -f1,2,3,4,5,6,7,8,9 >$GGSLAGFILE02
awk '{if ( $4 > 00 || $5 >=30 || $7 > 00 || $8 >=30 ) {print $1 " " $3 " HAS LAG of " $4" hour " $5 " min for checkpoint " $7 " hour " $8 " min -- at -- " d "n" }}' d="$(date)" $GGSLAGFILE02 > $GGSLAG_EMAIL
if [ -s $GGSLAG_EMAIL ]
then
mailx -s "${ORACLE_SID} Extract LAG ! on GoldenGate" "it.io.db.goldengate@vodafone.com" < $GGSLAG_EMAIL
exit 1
else
exit 0
fi
and
my crontab is
00,10,20,30,40,50 * * * * ksh /export/GoldenGate/scripts/check.sh 2>/dev/null
Advertisement
Answer
It’s possible that your:
/ggate/ggs11g/ggsci
which you call from
$MYGGSCI
requires some environment variables from the user you are running it as. To see if this is the issue, please modify the crontab entry like so:
00,10,20,30,40,50 * * * * . $HOME/.bashrc; /bin/ksh /export/GoldenGate/scripts/check.sh 2>/dev/null
The
. $HOME/.bashrc;
sources the environment variables from your “.bashrc” file.