Cron Issues

Hello everyone…

RT 3.6.3, RHEL, Oracle DB.

I have a cron job I created in cron.hourly…its pretty simplistic and
the command works great when I run it directly. Being very new to
Linux, I was hoping one of you may notice something simple that I am
missing here.

#!/bin/sh

/opt/rt3/bin/rt-crontool --search RT::Search::FromSQL --search-arg “(
Status = ‘new’ OR Status = ‘open’ OR Status = ‘stalled’ ) AND (
‘CF.{Severity Level}’ LIKE ‘Sev 2 (Premier Support ONLY)’ ) AND (
‘CF.{Customer}’ NOT LIKE ‘%§’ AND ‘CF.{Customer}’ NOT LIKE ‘%(ep)’ )”
–action RT::Action::DemotePremierLevel

Thanks,

-Stark

At Wednesday 7/11/2007 12:06 PM, Jeff Stark wrote:

Hello everyone…

RT 3.6.3, RHEL, Oracle DB.

I have a cron job I created in cron.hourly…its pretty simplistic
and the command works great when I run it directly. Being very new
to Linux, I was hoping one of you may notice something simple that
I am missing here.

#!/bin/sh

/opt/rt3/bin/rt-crontool --search RT::Search::FromSQL --search-arg
"( Status = ‘new’ OR Status = ‘open’ OR Status = ‘stalled’ )
AND ( ‘CF.{Severity Level}’ LIKE ‘Sev 2 (Premier Support ONLY)’ )
AND ( ‘CF.{Customer}’ NOT LIKE ‘%§’ AND ‘CF.{Customer}’ NOT LIKE
’%(ep)’ )" --action RT::Action::DemotePremierLevel

Thanks,

-Stark

Do you have any output from a cron run of this? It could be that the
cron invocation is not getting the Oracle environment variables it needs.

Steve

The only item in /var/log/cron is:

Jul 11 09:01:01 infrt01 crond[23295]: (root) CMD (run-parts
/etc/cron.hourly)

Is there somewhere else I should look?

Thanks,
-StarkFrom: Stephen Turner [mailto:sturner@MIT.EDU]
Sent: Wednesday, July 11, 2007 12:22 PM
To: Jeff Stark; RT Users
Subject: Re: [rt-users] Cron Issues…

At Wednesday 7/11/2007 12:06 PM, Jeff Stark wrote:

Hello everyone…

RT 3.6.3, RHEL, Oracle DB.

I have a cron job I created in cron.hourly…its pretty simplistic and
the command works great when I run it directly. Being very new to
Linux, I was hoping one of you may notice something simple that I am
missing here.

#!/bin/sh

/opt/rt3/bin/rt-crontool --search RT::Search::FromSQL --search-arg "(

Status = ‘new’ OR Status = ‘open’ OR Status = ‘stalled’ ) AND (
‘CF.{Severity Level}’ LIKE ‘Sev 2 (Premier Support ONLY)’ ) AND (
‘CF.{Customer}’ NOT LIKE ‘%§’ AND ‘CF.{Customer}’ NOT LIKE
’%(ep)’ )" --action RT::Action::DemotePremierLevel

Thanks,

-Stark

Do you have any output from a cron run of this? It could be that the
cron invocation is not getting the Oracle environment variables it
needs.

Steve

At Wednesday 7/11/2007 12:37 PM, Jeff Stark wrote:

The only item in /var/log/cron is:

Jul 11 09:01:01 infrt01 crond[23295]: (root) CMD (run-parts
/etc/cron.hourly)

Is there somewhere else I should look?

Thanks,
-Stark

I think any output (stdout or stderr) from the cron job that isn’t
explicitly redirected is mailed to the crontab owner. So there may be
a mail message that contains a clue.

Steve

Excellent! Had no idea…you are correct, it is Oracle Connectivity
that is causing the issue.

Any ideas how I solve this? I used the priority escalation script as a
template.

/etc/cron.hourly/RT-DemotePremier.cron:

Unable to load DBIx::SearchBuilder database handle for ‘Oracle’.
Perhaps you’ve picked an invalid database type or spelled it
incorrectly.
Can’t load
’/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBD/Orac
le/Oracle.so’ for module DBD::Oracle: libclntsh.so.10.1: cannot open
shared obje
ct file: No such file or directory at
/usr/lib/perl5/5.8.5/i386-linux-thread-mul
ti/DynaLoader.pm line 230.
at /usr/lib/perl5/site_perl/5.8.5/DBIx/SearchBuilder/Handle/Oracle.pm
line 6
Compilation failed in require at
/usr/lib/perl5/site_perl/5.8.5/DBIx/SearchBuild
er/Handle/Oracle.pm line 6.
BEGIN failed–compilation aborted at
/usr/lib/perl5/site_perl/5.8.5/DBIx/SearchB
uilder/Handle/Oracle.pm line 6.
Compilation failed in require at (eval 207) line 1.
BEGIN failed–compilation aborted at (eval 207) line 1.
Compilation failed in require at /opt/rt3/lib/RT.pm line 201.From: Stephen Turner [mailto:sturner@MIT.EDU]
Sent: Wednesday, July 11, 2007 12:57 PM
To: Jeff Stark; RT Users
Subject: RE: [rt-users] Cron Issues…

At Wednesday 7/11/2007 12:37 PM, Jeff Stark wrote:

The only item in /var/log/cron is:

Jul 11 09:01:01 infrt01 crond[23295]: (root) CMD (run-parts
/etc/cron.hourly)

Is there somewhere else I should look?

Thanks,
-Stark

I think any output (stdout or stderr) from the cron job that isn’t
explicitly redirected is mailed to the crontab owner. So there may be a
mail message that contains a clue.

Steve

At Wednesday 7/11/2007 01:07 PM, Jeff Stark wrote:

Excellent! Had no idea…you are correct, it is Oracle Connectivity
that is causing the issue.

Any ideas how I solve this? I used the priority escalation script as a
template.

/etc/cron.hourly/RT-DemotePremier.cron:

Unable to load DBIx::SearchBuilder database handle for ‘Oracle’.
Perhaps you’ve picked an invalid database type or spelled it
incorrectly.
Can’t load
’/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBD/Orac
le/Oracle.so’ for module DBD::Oracle: libclntsh.so.10.1: cannot open
shared obje
ct file: No such file or directory at
/usr/lib/perl5/5.8.5/i386-linux-thread-mul
ti/DynaLoader.pm line 230.
at /usr/lib/perl5/site_perl/5.8.5/DBIx/SearchBuilder/Handle/Oracle.pm
line 6
Compilation failed in require at
/usr/lib/perl5/site_perl/5.8.5/DBIx/SearchBuild
er/Handle/Oracle.pm line 6.
BEGIN failed–compilation aborted at
/usr/lib/perl5/site_perl/5.8.5/DBIx/SearchB
uilder/Handle/Oracle.pm line 6.
Compilation failed in require at (eval 207) line 1.
BEGIN failed–compilation aborted at (eval 207) line 1.
Compilation failed in require at /opt/rt3/lib/RT.pm line 201.

Another guess - do you have LD_LIBRARY_PATH defined? I think
$ORACLE_HOME/lib should be included in this path.

Steve

Yes, that is defined.

I have tried adding .bash_profile to my script…see if that worksFrom: Stephen Turner [mailto:sturner@MIT.EDU]
Sent: Wednesday, July 11, 2007 1:44 PM
To: Jeff Stark; RT Users
Subject: RE: [rt-users] Cron Issues…

At Wednesday 7/11/2007 01:07 PM, Jeff Stark wrote:

Excellent! Had no idea…you are correct, it is Oracle Connectivity
that is causing the issue.

Any ideas how I solve this? I used the priority escalation script as a

template.

/etc/cron.hourly/RT-DemotePremier.cron:

Unable to load DBIx::SearchBuilder database handle for ‘Oracle’.
Perhaps you’ve picked an invalid database type or spelled it
incorrectly.
Can’t load
’/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBD/Orac
le/Oracle.so’ for module DBD::Oracle: libclntsh.so.10.1: cannot open
shared obje ct file: No such file or directory at
/usr/lib/perl5/5.8.5/i386-linux-thread-mul
ti/DynaLoader.pm line 230.
at /usr/lib/perl5/site_perl/5.8.5/DBIx/SearchBuilder/Handle/Oracle.pm
line 6
Compilation failed in require at
/usr/lib/perl5/site_perl/5.8.5/DBIx/SearchBuild
er/Handle/Oracle.pm line 6.
BEGIN failed–compilation aborted at
/usr/lib/perl5/site_perl/5.8.5/DBIx/SearchB
uilder/Handle/Oracle.pm line 6.
Compilation failed in require at (eval 207) line 1.
BEGIN failed–compilation aborted at (eval 207) line 1.
Compilation failed in require at /opt/rt3/lib/RT.pm line 201.

Another guess - do you have LD_LIBRARY_PATH defined? I think
$ORACLE_HOME/lib should be included in this path.

Steve

At Wednesday 7/11/2007 02:15 PM, Jeff Stark wrote:

Yes, that is defined.

I have tried adding .bash_profile to my script…see if that works

It’s been a long while since I dealt with this issue, but I used to
have a file I called ~/.oracle, which set all the Oracle-related env
variables. I sourced this from my shell start up file (e.g. .bashrc)
and also in each crontab entry that needed Oracle access. That way I
was sure that both command-line and cron jobs were getting the same
Oracle environment.

Steve

This might be trivial but make sure the job is running the job as the
user you expect. If cron.hourly is being executed as root then it may
be reading the wrong files to setup the environment.

John J. Boris, Sr.
JEN-A-SyS Administrator
Archdiocese of Philadelphia
222 North 17th Street
Philadelphia, Pa. 19103
Tel: 215-965-1714
Fax: 215-587-3525
"Remember! That light at the end of the tunnel
Just might be the headlight of an oncoming train!"

Thanks, yes, actually I am expecting it to run as root. (I know bad
karma to follow)

But I am just trying to get it working. I have tried forcing the
loading of .bash_profile and have also tried adding the following to the
script:
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/client_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib

But I still get this error:

Unable to load DBIx::SearchBuilder database handle for ‘Oracle’.
Perhaps you’ve picked an invalid database type or spelled it
incorrectly.
Can’t load
’/usr/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/auto/DBD/Oracle/
Oracle.so’ for module DBD::Oracle: libclntsh.so.10.1: cannot open shared
object file: No such file or directory at
/usr/lib/perl5/5.8.5/i386-linux-thread-multi/DynaLoader.pm line 230.
at /usr/lib/perl5/site_perl/5.8.5/DBIx/SearchBuilder/Handle/Oracle.pm
line 6
Compilation failed in require at
/usr/lib/perl5/site_perl/5.8.5/DBIx/SearchBuilder/Handle/Oracle.pm line
6.
BEGIN failed–compilation aborted at
/usr/lib/perl5/site_perl/5.8.5/DBIx/SearchBuilder/Handle/Oracle.pm line
6.
Compilation failed in require at (eval 207) line 1.
BEGIN failed–compilation aborted at (eval 207) line 1.
Compilation failed in require at /opt/rt3/lib/RT.pm line 201.

This might be trivial but make sure the job is running the job as the
user you expect. If cron.hourly is being executed as root then it may
be reading the wrong files to setup the environment.

John J. Boris, Sr.
JEN-A-SyS Administrator
Archdiocese of Philadelphia
222 North 17th Street
Philadelphia, Pa. 19103
Tel: 215-965-1714
Fax: 215-587-3525
"Remember! That light at the end of the tunnel Just might be the
headlight of an oncoming train!"

At Wednesday 7/11/2007 03:50 PM, Jeff Stark wrote:

Thanks, yes, actually I am expecting it to run as root. (I know bad
karma to follow)

But I am just trying to get it working. I have tried forcing the
loading of .bash_profile and have also tried adding the following to the
script:
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/client_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib

But I still get this error:

Something that might help to debug this is to create a shell script
that just prints out the environment variables. Run this from the
command line and then from cron - see if you get everything you expect.

Steve

I got past the Oracle issues, so that all is working now…thanks so
much for all the help.

I can run the script directly and it works fine. However, when running
under CRON I get a new error now:

: bad interpreter: No such file or directoryotePremier.cron: /bin/sh
/etc/cron.hourly/RT-Resolved.cron:

Any thoughts?

Thanks!From: rt-users-bounces@lists.bestpractical.com
[mailto:rt-users-bounces@lists.bestpractical.com] On Behalf Of Stephen
Turner
Sent: Wednesday, July 11, 2007 3:55 PM
To: RT-Users@lists.bestpractical.com
Subject: RE: RE: [rt-users] Cron Issues…

At Wednesday 7/11/2007 03:50 PM, Jeff Stark wrote:

Thanks, yes, actually I am expecting it to run as root. (I know bad
karma to follow)

But I am just trying to get it working. I have tried forcing the
loading of .bash_profile and have also tried adding the following to
the
script:
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/client_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib

But I still get this error:

Something that might help to debug this is to create a shell script that
just prints out the environment variables. Run this from the command
line and then from cron - see if you get everything you expect.

Steve

http://lists.bestpractical.com/cgi-bin/mailman/listinfo/rt-users

Community help: http://wiki.bestpractical.com Commercial support:
sales@bestpractical.com

Discover RT’s hidden secrets with RT Essentials from O’Reilly Media.
Buy a copy at http://rtbook.bestpractical.com