Ever had to do a lot of DBVERIFY commands? You build a script, or multiple scripts, and when they start running you wish you had more or less of them? Here's a UNIX script that will run a dynamically variable number of concurrent dbv commands.
#!/usr/bin/ksh # # ************************************************************************* # * * # * Name : run_dbv.sh * # * Author : M. Vergara * # * Date : 29-Sep-2003 * # * Purpose : This script is designed to perform Oracle 'dbv' (dbverify) * # * commands against a list of files from a database. * # * * # * Change Log: * # * Chg# Date Description * # * ---- ----------- --------------------------------- * # * 1 20-Sep-2003 Created * # * * # ************************************************************************* # * Instructions: * # * 1) Copy this file from /usr/local/bin to a temporary working * # * directory. NEVER RUN THIS FILE FROM /usr/local/bin! * # * 2) Create your list of database files to be verified using whatever * # * tool you are comfortable with. 'grep', 'find', 'ls' are all valid * # * commands to use. Name the file "files_to_check.txt". * # * 3) (Optional) Create a file called "dbvcnt.max", containing one line * # * with the number of concurrent dbv processes that you wish to run. * # * The script builds a default file containing '4'. * # * 4) (Optional) Create a file called "dbvsleep.time", containing one * # * line with the number of seconds to sleep before checking the status* # * of the running processes. The script builds a default file with * # * a wait time of '21'. * # * 5) Set the Oracle environment variables for the instance you are * # * checking against. This script needs to know where $ORACLE_HOME is.* # * 6) Execute the script with ./run_dbv.sh. The script will start with * # * four concurrent sessions of dbv. If you decide that your system * # * is capable of running more than four, merely update the * # * "dbvcnt.max" file with the number of processes. It won't change * # * immediately, only when it reads the next line from the list of * # * database files. You can change this number up or down. * # * 7) The output log files from the 'dbv' commands are kept in the local * # * directory. You can look for files that fail with commands like: * # * grep -i fail *.log | grep -v ': 0' * # * 8) Modify as you see fit to make it work better for you. # * there # ************************************************************************* # * * # * (c) Copyright 2003 Guidant Corporation * # * No Warranty is expressed or implied. Use at your own risk. Works * # * best on HP-UX; your mileage may vary. Tastes great. Less Filling. * # * * # * M. Vergara 29-Sep-2003 * # ************************************************************************* # # # Existence Checks if ! [ -f files_to_check.txt ] ; then echo 007 echo Error! echo File "files_to_check.txt" is missing. Cannot continue. echo 007 exit 1 fi # if ! [ -f dbvcnt.max ] ; then echo 4 >
Requires Free Membership to View
dbvcnt.max
fi
#
if ! [ -f dbvsleep.time ] ; then
echo 21 > dbvsleep.time
fi
#
#
# Main
typeset -i BaseProcs=`ps | wc -l`
cat files_to_check.txt |
while read line
do
echo "-----"
date
FileName=`echo ${line} | awk -F/ ' { print $NF } '`
LogFileName=${FileName}.log
typeset -i NumProcs=`ps | wc -l`-${BaseProcs}
typeset -i MaxProcs=`cat dbvcnt.max`
typeset -i SleepTime=`cat dbvsleep.time`
#
echo ${NumProcs}
if [ ${NumProcs} -lt ${MaxProcs} ] ; then
echo Verifying file ${FileName}
${ORACLE_HOME}/bin/dbv file=${line} blocksize=8192 logfile=${LogFileName} & > /dev/null
sleep 1
else
until [ ${NumProcs} -lt ${MaxProcs} ]
do
typeset -i SleepCtr=0
echo "Max processes at `date`"
echo Sleeping c
while [ ${SleepCtr} -lt ${SleepTime} ]
do
sleep 1
typeset -i SleepCtr=${SleepCtr}+1
echo "."c
done
echo " "
typeset -i NumProcs=`ps | wc -l`-${BaseProcs}
done
echo Verifying file ${FileName}
/oracle/CTV/920_64/bin/dbv file=${line} blocksize=8192 logfile=${LogFileName} & > /dev/null
sleep 1
fi
done
#
# ###EOF###
For More Information
- Feedback: E-mail the editor with your thoughts about this tip.
- More tips: Hundreds of free Oracle tips and scripts.
- Tip contest: Have an Oracle tip to offer your fellow DBAs and developers? The best tips submitted will receive a cool prize -- submit your tip today!
- Ask the Experts: Our applications, SQL, database administration, and data warehousing gurus are waiting to answer your toughest questions.
- Forums: Ask your technical Oracle questions--or help out your peers by answering them--in our active forums.
- Best Web Links: Oracle tips, tutorials, and scripts from around the Web.
This was first published in October 2003

Join the conversationComment
Share
Comments
Results
Contribute to the conversation