Re: Why following ksh script not works in crontab?
Posted in 1998
Topics: Backup & Restore, Server Administration, Logging & Checkpoints, Platform-Specific Issues
Hi,
The reason this script will not work as a cron job as is, is because none
of the environment variables pertinent to Informix have been set.
As a minimum you will need to set INFORMIXDIR, ONCONFIG, and
PATH=$INFORMIXDIR/bin.
The reason for this is that when cron runs a job, it has no environment set
up at all, so does not where to look for Informix executables, or indeed
anything about the instance.
HTH
Stuart.
"If a mime threatens to commit suicide, is it considered a hostage
situation?"
______________________________ Reply Separator
_________________________________
Subject: Why following ksh script not works in crontab?
Author: rctwo@erols.com (Ruiming Chen <rctwo@erols.com>) at LEND
LEASE/LLAP
Date: 24/09/98 05:01
This is a multi-part message in MIME format.
--------------4D5164B43D5D4EE60DD563E6 Content-Type: text/plain;
charset=us-ascii Content-Transfer-Encoding: 7bit
The following ksh script works well in command line. But not work in
crontab, why?
--------------------------------------------------------------------
---
#!/bin/ksh
# Informix back up logical log and will create a file logical.log
ontape -a << EOF
^M
y^M
EOF
# where ^M is return input in vi by type ctrl-V and Enter
sleep 3
hour=`date +%H`
if [[ $hour -ge 9 && $hour -lt 12 ]]
then cp logical.log logical_tape1.log
else cp logical.log logical_tape2.log
fi
cat /dev/null > logical.log
-------------------------------------------------------------------
The above script runs perfectly if on command line. But when I
schedual
in the crontab, I always got 0 (zero) size of logical_tape1/2.log.
It
seems
to me the script does the "cp" command before the "ontape -a"
processing
finish. I even put a "sleep" between them. Why is that?
Do I have to run the script in background in crontab? like
0 10,13 * * * mybackup_script &
Currently I don't put in background "&"
BTW, My OS is HP-UX 10.20, database is Informix Dynamic Server 7.3. For
those who has OS Solaris 2.5/6.x, do you have this problem?
To all, do you have solution for me? Thank you very much in advance!
--
RC Square Team.
--------------4D5164B43D5D4EE60DD563E6
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Chui /Chen, Raymond/Ruiming
Content-Disposition: attachment; filename="vcard.vcf"
begin: vcard
fn: Raymond/Ruiming Chui /Chen
n: Chui /Chen;Raymond/Ruiming
org: RC Square
adr: ;;;;;;U.S.A.
email;internet: rctwo@erols.com
title: CS
tel;work: 301-498-8959
tel;fax: 301-498-8959
tel;home: URL http://www.erols.com/rctwo/
note: Raymond Chui & Ruiming Chen Company
x-mozilla-cpt: ;0
x-mozilla-html: TRUE
version: 2.1
end: vcard
--------------4D5164B43D5D4EE60DD563E6--