使用shell_exec运行shell命令

时间:2014-10-05 14:15:10

标签: php linux centos shell-exec

我使用ajax调用在服务器上执行“shell_exec”(centos)。 我执行的行是以下

echo shell_exec("php -q /websockets/timedactions.php");

这是服务器响应:

X-Powered-By: PHP/5.5.16
Access-Control-Allow-Origin: http://myIpAddress
Access-Control-Allow-Credentials: true
Content-type: text/html

0

运行此命令后,它应该激活的进程似乎没有运行。

使用root访问权限在shell上调用相同的命令

php -q /websockets/timedactions.php

完美无缺。

如何使用shell_exec使脚本正常工作?

1 个答案:

答案 0 :(得分:0)

执行命令时可能会出现错误。您可以将STDERR重定向到STDOUT,看看是否有like this(Sample 3.5)echo shell_exec("php -q /websockets/timedactions.php 2>&1");

也可能会阻止shell_exec打印(link)。