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

        <legend id='wtDxE'><style id='wtDxE'><dir id='wtDxE'><q id='wtDxE'></q></dir></style></legend>

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

        通过 cron 执行 PHP - 未指定输入文件

        Execute PHP via cron - No Input file specified(通过 cron 执行 PHP - 未指定输入文件)

          <tfoot id='bzRQa'></tfoot>
            <bdo id='bzRQa'></bdo><ul id='bzRQa'></ul>
              <tbody id='bzRQa'></tbody>

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

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

                <legend id='bzRQa'><style id='bzRQa'><dir id='bzRQa'><q id='bzRQa'></q></dir></style></legend>

                1. 本文介绍了通过 cron 执行 PHP - 未指定输入文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在使用以下命令通过 cron 执行 PHP 文件

                  I'm using the following command to execute a PHP file via cron

                  php -q /home/seilings/public_html/dvd/cron/mailer.php
                  

                  问题是我有一个包含在执行中的文件,该文件确定要加载的配置....例如:

                  The problem is that I Have a file that's included in the execution that determines which config to load.... such as the following:

                  if (!strstr(getenv('HTTP_HOST'), ".com")) {
                      $config["mode"] = "local";
                  } else {
                      $config["mode"] = "live";
                  }
                  

                  cron 正在加载本地配置,而它应该加载实时配置.我试过使用文件的 http://URL 而不是绝对路径,但没有找到该文件.我是否需要更改命令以使用其中的 URL?

                  The cron is loading the LOCAL config when it should be loading the LIVE config. I've tried using the http:// URL to the file instead of the absolute path but it didn't find the file. Do I need to change the command to use a URL within it?

                  推荐答案

                  使用这个 php_sapi_name() 检查脚本是否在命令行上被调用:

                  Use this php_sapi_name() to check if the script was called on commandline:

                  if (php_sapi_name() === 'cli' OR !strstr(getenv('HTTP_HOST'), ".com")) {
                      $config["mode"] = "local";
                  } else {
                      $config["mode"] = "live";
                  }
                  

                  如果您想在命令行上使用live",请使用以下代码:

                  If you want to use "live" on the commandline use this code:

                  if (php_sapi_name() === 'cli' OR strstr(getenv('HTTP_HOST'), ".com")) {
                      $config["mode"] = "live";
                  } else {
                      $config["mode"] = "local";
                  }
                  

                  这篇关于通过 cron 执行 PHP - 未指定输入文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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() 函数)

                      <bdo id='YHAYJ'></bdo><ul id='YHAYJ'></ul>
                      <legend id='YHAYJ'><style id='YHAYJ'><dir id='YHAYJ'><q id='YHAYJ'></q></dir></style></legend>
                        <tbody id='YHAYJ'></tbody>

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

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