0

我正在尝试在服务器上的 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 似乎没有运行该命令。如果我转到命令提示符并运行正常运行时间,我确实会看到结果。

我正在使用 ssh 进入 Linux 网络服务器。php 文件位于服务器上的我的文件夹中。

4

1 回答 1

0

我认为下面的代码会起作用。

The uptime for this system is <?php passthru('/usr/bin/uptime'); ?>

在 php 中执行系统命令,我建议您始终提供命令的完整路径。

于 2014-04-24T03:02:59.550 回答