分类: Sybase
2006-08-18 00:07:18
many tasks related to sybase ASE can only be executed after ASE is fully started, usually we can minitor the sybase errorlog or we isql into the ASE to see if the database is ready.
actually, there is a String in the errorlog we can determine ASE is fully started, it's "Recovery completed"
so if we can see this string in the end of errorlog, the ASE is fully started.
below is a script which can wait until ASE is fully start.
# waitsqlserver.sh
# determine if ASE is fully started, if yes in 10 minutes, return true; otherwise return false
READYMARK="Recovery complete"
typeset -i TRY=0 # TRY loop start from zero
typeset -i MAXTRY=60 # max try times, sp wait timeout will be MAXTRY * TRYINTERVAL = 600 = 10 minutes
typeset -i TRYINTERVAL=10 # unit is second, the time between 2 try
_isASEready() {
grep -q "$READYMARK" $TMPSTARTLOG
}
while (( TRY < MAXTRY ))
do
if _isASEready ; then
((STARTUPTIME=TRY*TRYINTERVAL))
echo $STARTUPTIME
export STARTUPTIME
exit 0
fi
((TRY=TRY+1))
sleep $TRYINTERVAL
done
exit 1