PHP: Require path does not work for cron job?

前端 未结 6 1314
后悔当初
后悔当初 2020-12-05 13:44

I have a cron job that needs to include this file:

require \'../includes/common.php\';

however, when it is run via the cron job (and not my

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-05 14:24

    Technically seen the php script is run where cron is located; ex. If cron was in /bin/cron, then this statement would look for common.php in /bin/includes/common.php.

    So yeah, you'll probably have to use fullpaths or use set_include_path

    set_include_path('/home/username123/public_html/includes/');
    require 'common.php';
    

提交回复
热议问题