php5 code on crontab failed

dmiebim used Ask the Experts™
Hi All,
I have a php5 script that runs well by manually. It connects a sybase db, makes same calculations and insert them in a sybase table. But, when I try to work it in crontab, I always getting this error;

"/usr/bin/php: error while loading shared libraries: cannot open shared object file: No such file or directory"

I've tried to put environment variables in the beginning of php code but didn't work.
Any idea?

Beginning of code is like this;

#!/usr/bin/php5 --
        putenv ("SYBASE=/home/sybase");
        putenv ("SYBASE_OCS=OCS-15_0");
        putenv ("SYBASE_ASE=ASE-15_0");
        putenv ("SYBASE_SYSAM=SYSAM-2_0");

        global $conn;
         $conn = sybase_connect('EBIMFS', 'radiousr', 'xxx');

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Most Valuable Expert 2011
Top Expert 2016

$SYBASE is undefined in the code snippet.  It looks like the script might depend on register_globals. See this page:
Hi dmiebim,
Looks to me as if the environment of your cron job is different from your own account (which is to be expected), and it seems that you might have already started looking down this path.
What is the full path to  One way to find it is by typing this at the UNIX/Linux command prompt:
Then make sure's directory is in the:
    putenv ("PATH=...

Or you could just login to your account, and type:
    echo $PATH
and make sure all the possibly relevant directories displayed are included in that
    putenv ("PATH=...
Most Valuable Expert 2011
Top Expert 2016
Agree with tel2 about the differing environment.  Here is a technique that I have used to debug CRON and other asynchronous jobs that do not have easy-to-read browser output.

At the logical top of the script, put

At the logical end of the script, put something like this:
$msg = ob_get_contents();
mail("", "CRON OUTPUT", $msg);

Assuming the script runs without any parse errors, you will get an email containing all the browser output, followed by the PHP information about the working environment.


problem resolved

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial