START_DATE=`date '+%d%m%Y%H%M%S'`
DAYOFWEEK=$(date +"%u")
START_HOUR=$(date +"%H")
run_dt=`date '+%d%m%Y'`
run_hr=`date '+%H%M'`
echo 'run_hr' $run_hr
echo 'Shell script started'
echo ${START_DATE}
echo ${DAYOFWEEK}
echo ${START_HOUR}
while [ $run_hr -lt 21];
do
if [ $DAYOFWEEK = 1 ] || [ $DAYOFWEEK = 2 ] || [ $DAYOFWEEK = 3 ] || [ $DAYOFWEEK = 4 ] || [ $DAYOFWEEK = 5 ] || [ $DAYOFWEEK = 6 ]; then
echo 'inside while'
sqlplus -s xx/abcd<< END2
set timing on;
select to_char(sysdate,'dd-mm-yyyyhh24:mi') starttime from dual;
#exec my_proc();
select to_char(sysdate,'dd-mm-yyyyhh24:mi') endtime from dual;
END2
sleep 120
let run_hr=`date '+%H%M'`
echo 'run_hr' $run_hr
elif [ $DAYOFWEEK = 7 ]; then
echo 'inside while on sunday'
sqlplus -s xx/abcd<< END2
set timing on;
select to_char(sysdate,'dd-mm-yyyyhh24:mi') starttime from dual;
#exec my_proc();
select to_char(sysdate,'dd-mm-yyyyhh24:mi') endtime from dual;
END2
sleep 120
if [ $run_hr -eq 14 ]; then
sleep 10800else
let run_hr=`date '+%H%M'`
echo 'run_hr' $run_hr
echo 'Nothing'
fi
else
echo 'off'
fi
done
echo 'Exiting'
by keeping in the while loop the proc runs every time by initiating at 9am in the morning by a cron. but on sunday, i have to keep it for 3 hrs in sleep at 14:00 hrs. can you please tell me how to keep that to sleep for 3 hrs on sunday. Thanks for the help in advance!
You could try to create another script (like a monitor script)that will execute the one that you posted: monitor_script: put it in crontab and executed it every minute procedure_script: your script
The purpose of monitor_script will be to:
Regards C