Re: Informix CRONTAB problem
Posted in 2005
On Wed, 2005-12-21 at 06:17, gary.cobden@nhs.net wrote:
> Morning all
>
> I have a problem with the following script which is designed to run a
> database export (dbexport) after cancelling all currently active
> sessions. It runs fine when run interactively:-
>
> cd /comwise343/etc/local
> mv cs_top cs_top_old
>
> cd /home/informix/bin
> rm sids
>
> dbaccess sysmaster <<!
> output to sids without headings
> select distinct (a.owner) from syslocks a, sysdatabases b
> where a.rowidlk = b.rowid
> and b.name = "comwise"> !
>
> for i in `cat sids`
> do
> onmode -z $i> done
>
> INFORMIXDIR=/usr/informix>
> export INFORMIXDIR
>
> INFORMIXSERVER=ONLINELIVE
> ONCONFIG=onconfig.live
> PATH=$PATH:$INFORMIXDIR/bin
>
> export INFORMIXSERVER ONCONFIG PATH>
> /usr/informix/bin/dbexport comwise -c -o /scratch/schema
>
> cd /comwise343/etc/local
> mv cs_top_old cs_top
>
> However, when run via a crontab command, the job fails with some or all
> of the following errors:-
>
> dbaccess: not found.
> cat: Cannot open sids: No such file or directory
> -425 - Database is currently opened by another user.
> -107 - ISAM error: record is locked.
>
> Any ideas please?
>
> I am aware that the last two errors relate to 'single user issues', but
> the first set of commands in the script kill active sessions
> interactively,and the script runs. So why not via CRONTAB
You're setting up the environment (INFORMIXDIR, PATH, etc.) only *after*
the dbaccess command for listing the active sids. When you're running
this from the command line, the environment presumably already contains
your INFORMIXDIR and PATH settings. Cron commands start with a clean
slate.
Therefore, the dbaccess command doesn't run, no list of active sids is
written, no active sessions are killed, and the export fails.
Hope this helps,
--
Carsten Haese | Phone: (419) 861-3331
Software Engineer | Direct Line: (419) 794-2531
Unique Systems, Inc. | FAX: (419) 893-2840
1687 Woodlands Drive | Cell: (419) 343-7045
Maumee, OH 43537 | Email: carsten@uniqsys.com
sending to informix-list