• <small id='hGUGO'></small><noframes id='hGUGO'>

      <i id='hGUGO'><tr id='hGUGO'><dt id='hGUGO'><q id='hGUGO'><span id='hGUGO'><b id='hGUGO'><form id='hGUGO'><ins id='hGUGO'></ins><ul id='hGUGO'></ul><sub id='hGUGO'></sub></form><legend id='hGUGO'></legend><bdo id='hGUGO'><pre id='hGUGO'><center id='hGUGO'></center></pre></bdo></b><th id='hGUGO'></th></span></q></dt></tr></i><div id='hGUGO'><tfoot id='hGUGO'></tfoot><dl id='hGUGO'><fieldset id='hGUGO'></fieldset></dl></div>
      <tfoot id='hGUGO'></tfoot>
    1. <legend id='hGUGO'><style id='hGUGO'><dir id='hGUGO'><q id='hGUGO'></q></dir></style></legend>
          <bdo id='hGUGO'></bdo><ul id='hGUGO'></ul>
      1. PHP:需要路径不适用于 cron 作业?

        PHP: Require path does not work for cron job?(PHP:需要路径不适用于 cron 作业?)
        <i id='wf5Gq'><tr id='wf5Gq'><dt id='wf5Gq'><q id='wf5Gq'><span id='wf5Gq'><b id='wf5Gq'><form id='wf5Gq'><ins id='wf5Gq'></ins><ul id='wf5Gq'></ul><sub id='wf5Gq'></sub></form><legend id='wf5Gq'></legend><bdo id='wf5Gq'><pre id='wf5Gq'><center id='wf5Gq'></center></pre></bdo></b><th id='wf5Gq'></th></span></q></dt></tr></i><div id='wf5Gq'><tfoot id='wf5Gq'></tfoot><dl id='wf5Gq'><fieldset id='wf5Gq'></fieldset></dl></div>

          • <bdo id='wf5Gq'></bdo><ul id='wf5Gq'></ul>

              <small id='wf5Gq'></small><noframes id='wf5Gq'>

              1. <legend id='wf5Gq'><style id='wf5Gq'><dir id='wf5Gq'><q id='wf5Gq'></q></dir></style></legend>
                <tfoot id='wf5Gq'></tfoot>
                  <tbody id='wf5Gq'></tbody>

                  本文介绍了PHP:需要路径不适用于 cron 作业?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个需要包含此文件的 cron 作业:

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

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

                  但是,当它通过 cron 作业(而不是我的本地测试)运行时,相对路径不起作用.cron 作业运行以下文件(在实时服务器上):

                  however, when it is run via the cron job (and not my local testing), the relative path does not work. the cron job runs the following file (on the live server):

                  /home/username123/public_html/cron/mycronjob.php
                  

                  这是错误:

                  Fatal error: require(): Failed opening required '../includes/common.php' 
                  (include_path='.:/usr/lib/php:/usr/local/lib/php') in 
                  /home/username123/public_html/cron/mycronjob.php on line 2
                  

                  使用与 cron 作业相同的绝对格式,common.php 将位于

                  using the same absolute format as the cron job, common.php would be located at

                  /home/username123/public_html/includes/common.php
                  

                  这是否意味着我必须将第 2 行替换为:

                  does that mean i have to replace my line 2 with:

                  require '/home/username123/public_html/includes/common.php';
                  

                  ?

                  谢谢!

                  推荐答案

                  从技术上看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';
                  

                  这篇关于PHP:需要路径不适用于 cron 作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Is PHP or PHP based web framework stateful or stateless?(PHP 或基于 PHP 的 Web 框架是有状态的还是无状态的?)
                  How to parse django style template tags(如何解析 django 样式模板标签)
                  What is a good setup for editing PHP in Emacs?(在 Emacs 中编辑 PHP 的好设置是什么?)
                  How to check whether specified PID is currently running without invoking ps from PHP?(如何在不从 PHP 调用 ps 的情况下检查指定的 PID 当前是否正在运行?)
                  What#39;s the difference between escapeshellarg and escapeshellcmd?(escapeshellarg 和escapeshellcmd 有什么区别?)
                  php in background exec() function(php 后台 exec() 函数)

                    <legend id='acW7O'><style id='acW7O'><dir id='acW7O'><q id='acW7O'></q></dir></style></legend>
                  1. <small id='acW7O'></small><noframes id='acW7O'>

                    <i id='acW7O'><tr id='acW7O'><dt id='acW7O'><q id='acW7O'><span id='acW7O'><b id='acW7O'><form id='acW7O'><ins id='acW7O'></ins><ul id='acW7O'></ul><sub id='acW7O'></sub></form><legend id='acW7O'></legend><bdo id='acW7O'><pre id='acW7O'><center id='acW7O'></center></pre></bdo></b><th id='acW7O'></th></span></q></dt></tr></i><div id='acW7O'><tfoot id='acW7O'></tfoot><dl id='acW7O'><fieldset id='acW7O'></fieldset></dl></div>

                    <tfoot id='acW7O'></tfoot>

                          <tbody id='acW7O'></tbody>

                            <bdo id='acW7O'></bdo><ul id='acW7O'></ul>