【发布时间】:2014-04-24 02:44:23
【问题描述】:
我正在尝试在服务器上的 php 文件中使用 linux 命令来获取正常运行时间,如下所示
<p> The uptime for this system is <?php $up_time=shell_exec('uptime');
echo $uptime; ?</p>
但是当我打开我的网页时,它只显示:
The uptime for this system is
PHP 似乎没有运行该命令。 如果我转到命令提示符并运行 uptime,我确实会看到结果。
我正在通过 ssh 进入 Linux 网络服务器。 php 文件位于服务器上我的文件夹中。
【问题讨论】:
-
我认为您在实际代码中正确关闭了
<?php,与上面的示例不同? -
你试过绝对路径吗? /bin/uptime Shell_exec 将在错误时返回 null。