Good day! I'm trying to figure out how to run a script that contains work with Oracle CRON database.
The script itself works if run through the browser. Starting by setting the task in CRON and displaying its result - I got errors like
Fatal error: Call to undefined function ociconnect
The problem is that if the script works through Apache2, then everything is fine, without Apache's participation, no.
Tried to delete comments - unsuccessfully, before
; extension = php_oci8.dll
; extension = php_oci8_11.g.dll
At the moment, when working out the script in CRON, no information is written to the file at all. CRON logs are fine, everything runs without errors. It is impossible to overcome this problem the third day. I ask your advice!
Addition :
php -r 'phpinfo ();' | grep php.ini

Configuration File (php.ini) Path => /etc/php/7.0/cli Loaded Configuration File => /etc/php/7.0/cli/php.ini 

The value of the variable ORACLE_HOME is not empty
ORACLE_HOME = / usr / lib / oracle / 12.2 / client64
The LD_LIBRARY_PATH value for the root user is missing.
For user LD_LIBRARY_PATH = / usr / lib / oracle / 12.2 / client64 / lib
There is also a difficulty in the fact that in the CRON task there are already tasks that are being carried out. I am afraid that altering the global variable may disrupt their work.

  • one
    look at the value of the LD_LIBRARY_PATH environment LD_LIBRARY_PATH in the shell from which the script works and provide the same value in the task launched from cron (for example, setting the variable globally in the crown settings or making a bash script that sets it and calls the php script. It will also be useful to ensure the values ​​of all variables environments starting with ORACLE_ , especially ORACLE_HOME - Mike
  • @Mike, thanks for the advice, went to google. - Eugene
  • 3
    It happens that php.ini is separate for apache and for cron execution. You can run php -r 'phpinfo();' | grep php.ini php -r 'phpinfo();' | grep php.ini php -r 'phpinfo();' | grep php.ini to find out which php.ini is used for the console. - Ivan Bolnikh
  • I think that the problem lies in the different environment (ENV) of the script, when you start it and when it starts CRON. These are different users, with different rights, different PATH, etc. Make the environment the same and everything will work! - Sergey
  • I solved the problem like this: in the /etc/profile.d directory I created oracle.sh with the content: export LD_LIBRARY_PATH = / usr / lib / oracle / 12.2 / client64 / lib export ORACLE_HOME = / usr / lib / oracle / 12.2 / client64 export PATH = $ PATH: $ ORACLE_HOME / bin - Eugene

0