skip to Main Content

I have a task script that works perfectly fine if i run it by visiting the php file from my browsers. However, when i attempt to run it via Plesk Task Scheduler it fail with a fatal error unable to load the require() file.

The require statement is a simple relative path:

require('../../../app.config.php');

the error is:

PHP Fatal error: require(): Failed opening required '../../../app.config.php'

I think this may be related to the include_path but i don’t know much about it so a bit lost on that one.

Any help would be great!

2

Answers


  1. You need to use absolute path. A different relative path may be produced if a script is called directly or the script is included in another script.

    For example:

    a.php is on path A/B/C the ../../ will result in in A/
    b.php is on path A/B/C/D, if it inlcudes the a.php then the ../../ on a.php will result in A/B/.
    
    Login or Signup to reply.
  2. relative pathes resolved by current directory. Solutions: Get script directory and combine with the relative path, something like:

     require(dirname(__FILE__).'/../../../app.config.php');
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search