bash - unix script should run 9-21 hrs on weekdays (mon-sat) and on sunday (9-14 and 17-21hrs). It executes a procecudure in oracle -
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]; if [ $dayofweek = 1 ] || [ $dayofweek = 2 ] || [ $dayofweek = 3 ] || [ $dayofweek = 4 ] || [ $dayofweek = 5 ] || [ $dayofweek = 6 ]; echo 'inside while' sqlplus -s xx/abcd<< end2 set timing on; select to_char(sysdate,'dd-mm-yyyyhh24:mi') starttime dual; #exec my_proc(); select to_char(sysdate,'dd-mm-yyyyhh24:mi') endtime dual; end2 sleep 120 let run_hr=`date '+%h%m'` echo 'run_hr' $run_hr elif [ $dayofweek = 7 ]; echo 'inside while on sunday' sqlplus -s xx/abcd<< end2 set timing on; select to_char(sysdate,'dd-mm-yyyyhh24:mi') starttime dual; #exec my_proc(); select to_char(sysdate,'dd-mm-yyyyhh24:mi') endtime dual; end2 sleep 120 if [ $run_hr -eq 14 ]; 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 while loop proc runs every time initiating @ 9am in morning cron. on sunday, have keep 3 hrs in sleep @ 14:00 hrs. can please tell me how keep sleep 3 hrs on sunday. in advance!
you try create script (like monitor script)that execute 1 posted: monitor_script: put in crontab , executed every minute procedure_script: script
the purpose of monitor_script to:
- check if procedure_script "up & running"
- execute procedure_script if reason goes down
- insert in monitor_script "if" like: if [ $dayofweek -eq 6 ] && [ $yourtimevar == "14" ];then sleep 3hrs fi
regards c
Comments
Post a Comment