Informix CRONTAB problem
Posted in 2005
Topics: Error Codes & Troubleshooting, Server Administration, Migration, Import/Export & Data Conversion
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 $idone
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
Help please.
Many thanks
Gary
Probably environment variables. Cron provides only a few env. variables to
scripts that it invokes, can't remember which ones, TZ and HOME I think.
So check everything else that you have in your environment when running the
script manually and see if you need to export it in the environment when
running from cron (PATH, for example).
<gary.cobden@nhs.net> wrote in message
news:1135163833.258647.116960@g49g2000cwa.googlegroups.com...
> 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
>
> Help please.
>
> Many thanks
>
> Gary
>
Problem is due to different environment in sh, bash (after login) compared
to cron.
> dbaccess: not found.
dbaccess is not in $PATH when job is startet in cron-environment, not even
~.
try ./dbaccess od full pathname to dbaccess command. in script.
> cat: Cannot open sids: No such file or directory
consequently output to sids failed before, after "rm sids" sids is no longer
there.
> -425 - Database is currently opened by another user.
?? i have no idea ??
> -107 - ISAM error: record is locked.
try "set isolation dirty read" statement before forther sql commands.
> > -425 - Database is currently opened by another user.
> ?? i have no idea ??
Is this not from the dbexport command (which incidently was fully
qualified and hence this error message is expected if the database is
'opened by another user' - which also indicates the likelihood of the
dbaccess actually working were it also to be fully qualified (as
suggested by Andreas.) )
Cheers,
Andreas Kress wrote:
> Problem is due to different environment in sh, bash (after login) compared
> to cron.
>
> > dbaccess: not found.
> dbaccess is not in $PATH when job is startet in cron-environment, not even
> ~.
> try ./dbaccess od full pathname to dbaccess command. in script.
>
> > cat: Cannot open sids: No such file or directory
> consequently output to sids failed before, after "rm sids" sids is no longer
> there.
>
> > -425 - Database is currently opened by another user.
> ?? i have no idea ??
>
> > -107 - ISAM error: record is locked.
>
> try "set isolation dirty read" statement before forther sql commands.
At the top of your script, "dot-in" your profile or in the case
of many Linux and UNIX systems you can dot-in the /etc/profile
provided it has the environment variables you need. Check with
your sys admin on that. In the meantime, try using your own
profile or bashrc or whatever you prefer.
. /path/to/my/profile
This will pull in your environment into the script just as if
you yourself had logged in.
If in doubt as to whether or not you are getting all the stuff
you need from the environment, you can
env | sort > myenv.txt
This will contain everything in your environment, sorted, that
you can use to construct a new profile. Be sure to use the
export command on each variable to make sure it travels to the
next process.
Happy Holidays!
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
>
> Help please.
>
> Many thanks
>
> Gary
>