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

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

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

        无法运行 PHP cron 脚本

        时间:2023-10-04
          <i id='x2iNd'><tr id='x2iNd'><dt id='x2iNd'><q id='x2iNd'><span id='x2iNd'><b id='x2iNd'><form id='x2iNd'><ins id='x2iNd'></ins><ul id='x2iNd'></ul><sub id='x2iNd'></sub></form><legend id='x2iNd'></legend><bdo id='x2iNd'><pre id='x2iNd'><center id='x2iNd'></center></pre></bdo></b><th id='x2iNd'></th></span></q></dt></tr></i><div id='x2iNd'><tfoot id='x2iNd'></tfoot><dl id='x2iNd'><fieldset id='x2iNd'></fieldset></dl></div>
          <legend id='x2iNd'><style id='x2iNd'><dir id='x2iNd'><q id='x2iNd'></q></dir></style></legend>

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

            • <bdo id='x2iNd'></bdo><ul id='x2iNd'></ul>
              • <tfoot id='x2iNd'></tfoot>

                    <tbody id='x2iNd'></tbody>

                  本文介绍了无法运行 PHP cron 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有一个需要每分钟运行一次的 PHP 脚本.我已经确保脚本可以从命令行运行,并且我使用绝对路径来避免任何环境问题:

                  I have a PHP script that I need to run every minute. I have made sure that the script works from the command line, and I'm using absolute paths to avoid any environment issues:

                  /usr/bin/php -q /var/www/myapp/services/myservice.php
                  

                  从命令行以 root 用户身份手动运行它可以正常工作,正如我从脚本写入的日志文件中看到的那样.可以肯定的是,该脚本也具有执行权限.

                  Manually running that as root from the command line works fine, as I can see from the log file that my script writes to. To be sure, the script has execute permissions as well.

                  但是,当在 cron 中放置相同的命令时:

                  However, when placing the same exact command in a cron:

                  * * * * * /usr/bin/php -q /var/www/myapp/services/myservice.php
                  

                  它没有运行,或者至少看起来是这样.我也尝试将输出重定向到另一个日志文件:

                  It does not run or at least it appear so. I've tried redirecting the output to another log file too:

                  * * * * * /usr/bin/php -q /var/www/myapp/services/myservice.php >> /mylog.log 2>&1
                  

                  还是没有.我没有任何迹象表明正在运行的脚本.我想它没有,但我不知道还要寻找什么.我什至重新启动了 cron 守护进程.

                  Still nothing. I have no indication whatsoever of the script being ran. I guess it doesn't, but I have no idea what else to look for. I even restarted the cron daemon.

                  我知道在 StackOverflow 上也有类似的问题,但没有一个答案对我来说是一个解决方案.这简直让我发疯了,我将不胜感激任何帮助.

                  I know there are similar questions on StackOverflow, but none of the answers turned out to be a solution for me. This is literally driving me crazy, I will greatly appreciate any help.

                  推荐答案

                  我找到了解决我的问题的方法:

                  I found a solution for my issue:

                  https://serverfault.com/questions/97828/php-from-command-line-path-problems/97881#97881

                  事实证明我需要 cd(更改目录)到脚本目录中,然后调用它.令人惊讶,因为我使用的是绝对路径,但它有效.感谢那些花时间回复的人.

                  It turns out I needed to cd (change directory) into the script dir and then call it. Surprising, since I'm using absolute paths, but it works. Thanks to those who have taken the time to respond.

                  这篇关于无法运行 PHP cron 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如何确定是否通过 cron/命令行加载了 PHP 文件 下一篇:奇怪的回声,PHP 中的打印行为?

                  相关文章

                  最新文章

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

                  2. <small id='afwVz'></small><noframes id='afwVz'>

                    1. <legend id='afwVz'><style id='afwVz'><dir id='afwVz'><q id='afwVz'></q></dir></style></legend>
                        <bdo id='afwVz'></bdo><ul id='afwVz'></ul>