Re: cron and isql
Posted in 1995
There is no reason why you should not be able to get the two (cron and
isql) to work. However, you must be very careful to set the environment
variables in the script run by cron as scripts run by cron have no
environment worth mentioning -- $HOME and an utterly minimal $PATH is all
you can rely on. I normally put together a generic script which (1) sets
the Informix and application environment for cron, and (2) which then
inspects $0 and runs the corresponding script from another directory.
Typically, there is a directory $PROJECTDIR/bin/Cron containing run_cron
linked to the various commands run by cron. The crontab entries reference
$PROJECTDIR/bin/Cron/some_cmd and the script ends up running
$PROJECTDIR/bin/some_cmd.
One example, derived from a real project, is shown below. As you can see,
this was done some time ago, but as far as I know it is still in use. The
XXmail script only sent mail if there was any useful information to send --
all blank messages are suppressed. It also determines the list of
recipients from a configuration file so that the administrative messages
are sent to the right people.
Yours,
Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>
>Date: Tue, 17 Jan 1995 16:11:48 +0000
>From: johnson@hqcso.attmail.com
>Subject: cron and isql
>X-Informix-List-Id: <list.5343>
>
> Hi!
> We are successful running loads and ACE reports in cron, but are
> not able to do isql updates in cron. We were told that this is not
> supported. Is this true? Anyone have any suggestions?
> We are running this on an AT&T 3B2 with Informix 2.10 SE (yes, old
> stuff). We are moving to current version of SE on an NCR box soon.
> Don't know if the problem occurs on new box yet.
> And we think we have all the environment variable set (PATH, INFORMIXDIR,
> DBPATH) correctly.
---------------------------------------------------------------------------
: "@(#)cron.doit.sh 1.2 91/01/28"
#
# XXXXXXXXXXXXXXX System
#
# Generic script to run programs from CRON(1).
# NB: Cron runs this script with a minimal environment.
# The variables: PATH, HOME are set to defaults.
# Reset environment for CRON
. $HOME/.cronfile
# Run named program, trapping output and sending it to XX administrator.
arg0=`basename $0 .sh`
$arg0 ${@:+"$@"} 2>&1 | XXmail -s "CRON: output from $arg0"
---------------------------------------------------------------------------
The .cronfile used looked like:
---------------------------------------------------------------------------
: "@(#).cronfile.sh 1.3 91/03/27"
#
# XXXXXXXXXXXXXXX System
#
# Profile for CRON-run scripts
# This is a subset of the information in .profile
# It would probably be better if this lot was factored out of .profile
# and into a file such as .environ, and then .environ was used in both
# .profile and .cronfile.
: ${INFORMIXDIR:=/usr/informix}
export INFORMIXDIR
PROJECTDIR=$HOME
export PROJECTDIR
MAILRC=/dev/null
export MAILRC
PATH=$HOME/bin:/bin:/usr/bin:$INFORMIXDIR/bin:.export PATH
# Compiling options
FGLTYPE=c4gl
export FGLTYPE
I4GL_TYPE=c4gl
export I4GL_TYPE
MAKE=rmk
export MAKE
# Database environment
DBEDIT=vi
export DBEDIT
DBDATE=dmy4/export DBDATE
DBMENU=XXX
export DBMENU
DBPATH=$HOME/frm:$DBPATHexport DBPATH
umask 002
---------------------------------------------------------------------------