且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PHP:需要路径不适用于 cron 作业?

更新时间:2023-11-29 17:27:52

从技术上看php脚本是在cron所在的地方运行的;前任.如果 cron 在/bin/cron 中,则该语句将在/bin/includes/common.php 中查找 common.php.

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.

是的,您可能必须使用完整路径或使用 set_include_path

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';