I'm trying to execute a shell with crontab. The cron job executes the shell but doesn't generate the log file i need.
This is what i'm using for my cron: 10 * * * * /home/user/3nvo.sh
This is a simple shell that has the same structure:
#! /bin/bash
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/MCMMX
export OH=$ORACLE_HOME
export SHLIB_PATH=$ORACLE_HOME/lib:/usr/lib/Motif1.2
export ORACLE_SID=MCMMX
export ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data
export TMPDIR=/tmp
export DESA_HOME=/home/manager
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
export FECHA=`date +"%d-%m-20%y_%H:%M:%S"`
PATH=$PATH:.:/opt/bin:$ORACLE_HOME/bin:/bin:/usr/bin:/usr/ccs/bin:/usr/sbin:/opt/perl:/opt/p erl/bin:/usr/kerberos/bin
ERROR="error_carga_nextone_$FECHA.log"
WARNING="warning_$FECHA.log"
DUMMY="dummy.txt"
if [ -r $DUMMY ]; then
echo "you have an instance open" >> $WARNING
else
echo "rest of the shell script"
fi >& carga_$FECHA.log
When the cron job starts the shell executes and this generates the log WARNING but doesn't generate the log carga_$FECHA.log that's on the end of the if statement. I tried adding 2>> carga_$FECHA.log and it sends me an e-mail with the content of the log file and then this:
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin>
X-Cron-Env: <HOME=/home/ecabanas>
X-Cron-Env: <LOGNAME=ecabanas>
X-Cron-Env: <USER=ecabanas>