Re: Odp: crontab + ontape
Posted in 1998
Neil_Truby wrote:
>
> In article <JYLbhBAuhBy1QAUn@century.demon.co.uk>, Simon says...
> >
> >
> >Create a script to run the ontape backup and schedule this via Cron.
>
> Have you ever found a satisfactory method of limiting the number of attempts
> made if the tape is for some reason not available? We occasionally get the
> situation whereby the log fills with repeated "Mount tape" messages. I've seen
> some suggestions for limiting the number of tries, but have never got any of
> them to work.
>
> Neil Truby
> Chase Manhattan Bank
> Bournemouth, UK
Hi Neil,
recently I made this work by writing kind of a watchdog script which
checks the ontape process. I let ontape log its output and the
watch process checks the logfile for an error message and issues a
kill -15 to end the ontape process.
Here are the sources (please note that I'm not that specialist in
writing Unix shell scripts, but it's more important to me that it
works though I think there is a much more elegant way of achieving
the same result):
ontape.sh
---------
# Automatic backup via cron
echo "DB backup start: `date`"
INFORMIXDIR=/usr3/informix export INFORMIXDIR
ONCONFIG=onconfig.1 export ONCONFIG
PATH=$INFORMIXDIR/bin:$PATH export PATH
INFORMIXSERVER=media export INFORMIXSERVER
# Backup cancelled
cancel ()
{
echo "DB backup stop: `date`"
# Free unused shmem which was reserved during ontape
onmode -F
rm -f ontape.log
exit 1
}
# Backup
# Start the watch process in background with current PID
chktapelog $$ &
# Start backup (backupinf.cr holds only a carriage return) and
# log output to ontape.log; if ontape is cancelled script is
# exited via function cancel
ontape -s <<EOF > ontape.log || cancel
EOF
if test $? -eq 0
then
# Free unused shmem which was reserved during ontape
onmode -Ffi
rm -f ontape.log
echo "DB backup end: `date`"
chktapelog
----------
# Check ontape process
# Just wait 'til ontape was started
sleep 2
# $1 holds the parent PID
INPUT_ID=$1
# Check ontape.log for error message
grep -i "could not write archive tape" ontape.log > /dev/null
if test $? -eq 0
then
# Get PID of ontape
set `ps -eaf | grep "[0-9] ontape -s$"`
CHILD_ID=$2
PARENT_ID=$3
if [ $PARENT_ID -eq $INPUT_ID ]
then
kill -15 $CHILD_ID
fi
fi
If there is any other (or even better ;-) solution please drop a line!
Just my 2 (or maybe 3) cents worth... :-)
Regards,
Stephan.
--
Stephan Stresing
Media Systeme
Gesellschaft fuer Druck & Verlag mbH
Suedwestpark 48
D-90449 Nuernberg
Phone +49 911 6809-113
Fax +49 911 6809-110
eMail triple-p.sst@t-online.de
WWW http://www.mediasys.triple-p.com