Home: Perl Programming Help: DBI:
DBD::ODBC runs manually, not via crontab



islanderman
Novice

May 5, 2014, 8:01 AM


Views: 89165
DBD::ODBC runs manually, not via crontab

I installed DBD::ODBC and everything runs fine from a non-root account via command line, but just not via crontab. The module is located here:

/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/DBD/ODBC.pm

I ran a crontab entry to capture the perl libraries from the account and I see the path :

/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.8
/usr/lib/perl5/site_perl
/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.8
/usr/lib/perl5/vendor_perl
/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi
/usr/lib/perl5/5.8.8


Can someone help with what I'm missing, or help capturing what the error actually is? I am not even doing anything, like connecting to a DB. I just am running a bare bones perl script with the 'use DBD::ODBC' in it.


Laurent_R
Veteran / Moderator

May 5, 2014, 11:42 PM


Views: 88866
Re: [islanderman] DBD::ODBC runs manually, not via crontab

I had a similar problem with an Oracle database: the script would run fine when launched manually from my account but would fail when launched vie the crontab. It turned out that the problem did not have to do with Perl (I reproduced it with a shell script and sqlplus commands), but with some environment variables needed to be able to connect to the Oracle database, which were not set for the root account. You might have a similar problem.