On 3/25/07, Reidy, Ron <[EMAIL PROTECTED]> wrote:

This tells me there is something not set in your environment.  Have you
tried setting the environment like I specified?


Here's a handy method for getting the environment correct
in a script (DBI or otherwise) to run from cron when all
else seems to fail.

Most here probably know that cron does not setup the environment
when it runs a job.  That is left up to you.

When a script is run withe 'at' utility however, entire environment is
dumped into a file to be used by 'at'.

Setup your job to run in the future with 'at', then you can use the
contents of the 'at' script to build a script for cron.  I've used this
a couple times when scripts failed to run in cron, though I seemed
to have included every possible env variable.

example - run ls 1 hour from now:

9:12-jkstill-2 > at now + 1 hour
at> ls -l
at> <EOT>
job 2 at 2007-04-11 10:13
[ /home/jkstill/tmp ]

9:13-jkstill-2 >

Now as root, navigate to the /var/spool/at directory.

[root /]# cd /var/spool/at
[root at]# ls -ltr
total 16
drwx------  2 daemon  daemon 4096 Dec 28 10:26 spool
-rwx------  1 jkstill dba    3685 Apr 11 09:13 a00002012b26c9
[root at]#

The file a00002012b26c9 has all of my environment in it, followed by the
command to run.
There will be number of things that can obviously be removed from the file.

eg.

[root at]# cat a00002012b26c9
#!/bin/sh
# atrun uid=501 gid=300
# mail  jkstill 0
umask 27
PATH=/home/jkstill/bin:/bin:/:/u01/app/perl/bin:/usr/bin:/usr/local/sbin:/usr/lib:/etc:/usr/local/bin:/home/jkstill/bin:/bin:/:/u01/app/perl/bin:/usr/bin:/usr/local/sbin:/usr/lib:/etc:/usr/sbin:/home/jkstill/perl:/usr/X11R6/bin:/u01/app/oracle/product/9.2.0/9ir2dev/bin;
export PATH
...
${SHELL:-/bin/sh} << `(dd if=/dev/urandom count=200 bs=1
2>/dev/null|LC_ALL=C tr -d -c '[:alnum:]')`

ls -l

HTH

--
Jared Still
Certifiable Oracle DBA and Part Time Perl Evangelist

Reply via email to