1847253 Members
4394 Online
110263 Solutions
New Discussion

Re: Script question

 
wvsa
Regular Advisor

Script question

Good morning admins. Have a quick questions regarding the following script:
# begin script
PATH=/sbin:/usr/sbin:/usr/bin:/opt/omni/lbin:/opt/omni/bin
export PATH

if [ $SMEXIT != 0 ]
then
/opt/omni/lbin/backuperr

exit 0

else
echo "Successful Backup"
echo "Now submitting Daily_PROD_2_ULT backup run."
omnib -datalist Daily_PROD_2_ULT -no_monitor
touch /tmp/daily_prod_2_ult
echo `date` >> /tmp/daily_prod_2_ult
fi

echo "${progname} completed!"

exit 0

Would like to have the omnidb process complete before the file is touched, in effect have the script suspend until the Omniback backup is complete, once the backup is complete then have the file created. THankyou in advance for input.


8 REPLIES 8
Fred Ruffet
Honored Contributor

Re: Script question

omnib surely starts backup in background.
you should use wait to be sure omnib is finished.

Try to look how this can be merged in your script (might be better with awk, but...)

#!/bin/sh

nohup sleep 5 >/dev/null 2>&1 &
SleepPID=`ps -edf | grep "sleep 5" | \
grep -v grep | tr "[:blank:]" " " | \
sed "s/ */ /" | cut -d " " -f 3`
wait $SleepPID
echo I waited for sleep to finish
--

"Reality is just a point of view." (P. K. D.)
Sundar_7
Honored Contributor

Re: Script question

Hi,

# begin script
PATH=/sbin:/usr/sbin:/usr/bin:/opt/omni/lbin:/opt/omni/bin
export PATH

if [ $SMEXIT != 0 ]
then
/opt/omni/lbin/backuperr

exit 0

else
echo "Successful Backup"
echo "Now submitting Daily_PROD_2_ULT backup run."
omnib -datalist Daily_PROD_2_ULT -no_monitor
wait
touch /tmp/daily_prod_2_ult
echo `date` >> /tmp/daily_prod_2_ult
fi

echo "${progname} completed!"

exit 0

I am not sure if this will work - but try it out.


Sundar
Learn What to do ,How to do and more importantly When to do ?
Sanjay_6
Honored Contributor

Re: Script question

Hi,

You can remove the no_moitor option and check for RC and if you get a RC=0 then touch the file, else exit.

omnib -datalist Daily_PROD_2_ULT
if [ $rc = 0 ]
then
touch /tmp/daily_prod_2_ult
else
fi

Hope this helps.

Regds


Leif Halvarsson_2
Honored Contributor

Re: Script question

Hi,
The correct solution is to run
touch /tmp/daily_prod_2_ult

as a post_exec script in the

Daily_PROD_2_ULT

datalist
RAC_1
Honored Contributor

Re: Script question

Change following code
else
echo "Successful Backup"
echo "Now submitting Daily_PROD_2_ULT backup run."
omnib -datalist Daily_PROD_2_ULT -no_monitor
touch /tmp/daily_prod_2_ult
echo `date` >> /tmp/daily_prod_2_ult
fi

TO

else
echo "Successful Backup"
echo "Now submitting Daily_PROD_2_ULT backup run."
omnib -datalist Daily_PROD_2_ULT -no_monitor && touch /tmp/daily_prod_2_ult
echo `date` >> /tmp/daily_prod_2_ult
fi

(See the use of &&)

Anil
There is no substitute to HARDWORK
Leif Halvarsson_2
Honored Contributor

Re: Script question

Sorry,
I noticed that your script is a post_exec script (the SMEXIT variable) and you want to start a another backup from that script (consecutive backup).

You could use a post_exec script for the second backup which do the:
if [ $SMEXIT = 0 ]
then
touch /tmp/daily_prod_2_ult
echo `date` >> /tmp/daily_prod_2_ult

echo "${progname} completed!"
else

........

fi


Or you can use the same post_exec script for both jobs and use the variable
DATALIST
to chech which of the two jobs is runnnin and what should be done.
wvsa
Regular Advisor

Re: Script question

RAC, what does the && do? Could you provide a brief explanation? Thankyou!!
Stuart Browne
Honored Contributor

Re: Script question

"Execute upon successful completion of the previous task", as against || which is "Execute upon un-successful completion of previous task".

If the previous task is backgrounding off however, then it won't be much help, as the return is still immediate.
One long-haired git at your service...