【问题标题】:Can't Find PHP Script as Running Process on Linux Operating System?在 Linux 操作系统上找不到 PHP 脚本作为运行进程?
【发布时间】:2014-12-22 17:27:58
【问题描述】:

我的 Amazon Linux 上有一个 PHP 文件,看起来像

<?php

sleep(600);

我通过点击一个公开的 URL 来运行该文件。当文件运行时,我运行

ps aux

在我的 Linux 机器上,但我无法从列表中找到相应的进程。我也试过了

ps ax | grep *.php

不返回任何结果。

为什么我找不到我的 PHP 进程?

【问题讨论】:

  • 因为您可能在 apache 中运行 PHP,这意味着您只会看到 Apache 的子代,而看不到 PHP 本身。您必须查看打开的文件并找到打开您的 .php 脚本文件的 httpd 孩子。
  • 它实际上是一个进程吗?你有一个刚刚运行的脚本吗?那么,当您运行 ps 命令时,一切都是在事后发生的吗?你有它作为每 1 分钟运行一次的 cron 吗?
  • @MarcB 在 httpd 中查看打开文件的命令是什么?
  • fuser,如果已安装
  • 你可以使用这个命令: sudo lsof -c httpd 这显示了按名称打开的文件。 -c 选项搜索模式

标签: php linux process ps


【解决方案1】:

只要发出这个命令

 ps aux | grep php

不要发*.php

我刚刚在我的盒子上做了ps aux | grep php,我得到了以下输出

ps aux | grep php
root      6156  0.0  0.1 189700  4128 pts/9    T    12:00   0:00 sudo emacs MissionAgreement.php -nw
root      6168  0.1  0.4 252820 16864 pts/9    T    12:00   0:02 emacs MissionAgreement.php -nw
gain-dev  6387  0.0  0.1 230632  4640 ?        Sl   12:13   0:00 /usr/lib64/libreoffice/program/oosplash --writer /var/www/html/wwwroot/phpword/samples/gain_docx_template/MissionAgreement_.docx
gain-dev  6400  4.1  6.0 1515164 237840 ?      Sl   12:13   0:45 /usr/lib64/libreoffice/program/soffice.bin --writer /var/www/html/wwwroot/phpword/samples/gain_docx_template/MissionAgreement_.docx --splash-pipe=6
gain-dev  6869  0.0  0.0 103252   828 pts/9    S+   12:32   0:00 grep php
root     20355  0.0  0.0 189700     8 pts/9    T    Dec19   0:00 sudo emacs Invoice.php -nw
root     20483  0.0  0.0 252612     8 pts/9    T    Dec19   0:01 emacs Invoice.php -nw
gain-dev 29811  0.0  0.2 404620 10492 ?        S    Dec18   1:54 gedit /home/gain-dev/.cache/.fr-HxN35J/index.php
root     30741  0.0  0.0 189704     8 pts/0    T    Dec16   0:00 sudo emacs gain_fns.php -nw
root     30743  0.0  0.0 252288     8 pts/0    T    Dec16   0:00 emacs gain_fns.php -nw
root     31164  0.0  0.0 189700     8 pts/0    T    Dec16   0:00 sudo emacs /etc/php.ini -nw
root     31174  0.0  0.0 250640     8 pts/0    T    Dec16   0:00 emacs /etc/php.ini -nw
root     31380  0.0  0.0 189704     8 pts/0    S    Dec16   0:00 sudo emacs mission_insert.php -nw
root     31382  0.0  0.3 252664 12464 pts/0    S+   Dec16   0:01 emacs mission_insert.php -nw

如果上面的示例有问题,您也可以启用带有 ExtendedStatus 的 mod_status 将显示当前正在处理的 pid 和 URL。你会在这个 url 上得到一个很好的输出和一个例子:http://www.apache.org/server-status

【讨论】:

    猜你喜欢
    • 2011-08-24
    • 1970-01-01
    • 2010-11-06
    • 2010-10-20
    • 2017-09-10
    • 1970-01-01
    • 1970-01-01
    • 2021-03-10
    • 2015-03-29
    相关资源
    最近更新 更多