update statistics script
Posted in 1999
Topics: Server Administration
hi,
I am looking for a way to run update statistics script from cron against 4
different instances. A script that includes user informix, environment
variables, and sql (dbaccess dbname xxx.sql). The ability to set environment
variables after (su informix) seems to be hangup. Any help is appreicated.
Bye
Jim
In article <7iicdd$g0n$1@news.xmission.com>,
"James R. Swallow" <jswallow@greenbay.k12.wi.us> wrote:
>
> hi,
>
> I am looking for a way to run update statistics script from cron against 4
> different instances. A script that includes user informix, environment
> variables, and sql (dbaccess dbname xxx.sql). The ability to set environment
> variables after (su informix) seems to be hangup. Any help is appreicated.
You may try something like this this:
. /usr/informix/etc/profile.prod # source Informix variables
for instance in inst1 inst2 inst2 inst4; do
INFORMIXSERVER=$instance export INFORMIXSERVER
echo "update statistics" | $INFORMIXDIR/dbaccess <your_db_name>
done
If you have different onconfig files for different instances will need to set
ONCONFIG parameter as well.
Alex.
--
Before the accident, I even could not spell UNIX
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
"James R. Swallow" wrote:
>
> hi,
>
> I am looking for a way to run update statistics script from cron against 4
> different instances. A script that includes user informix, environment
> variables, and sql (dbaccess dbname xxx.sql). The ability to set environment
> variables after (su informix) seems to be hangup. Any help is appreicated.
First, why are you doing su - informix? I assume it is to get the
environment set up properly. Make the crontab an informix crontab
(ie enter it while logged in as informix). This will set the script's
userid and home directory. Then make the cron script looks like this:
. ./.profile # Execute user informix's $HOME/.profile file
# The ". " tells the current shell to execute the
# script itself and not start a sub-shell so the
# environment vars get set permanently for the session.
# Same for the instance scripts below.
. bin/instance.1.environment # Set the env to point to instance #1
updstats.instance.1.ksh
. bin/instance.2.environment # Set the env to point to instance #2
updstats.instance.2.ksh
#OR
dbaccess database2 - <updstats.database2.sql
#OR
dostats -d database2 -h inst2_tcp_conn
#OR for all of the multiple databases in an instance:
dostats -d all -h inst2_tcp_conn
BTW if all instances share an INFORMIXDIR and only the INFORMIXSERVER
and ONCONFIG values are different then if you use ksh or bash (not sh
or csh) it is sufficient to do:
INFORMIXSERVER=instance1 ONCONFIG=inst.1.conf updstats.instance.1.ksh
INFORMIXSERVER=instance2 ONCONFIG=inst.2.conf updstats.instance.2.ksh....
Which goes directly to the named instance as its default connection.
Art S. Kagel