0

有时我的媒体服务器出现故障,我想知道是否可以使用 php 远程启动它来检查端口,以及它是否没有运行调用 cron(或其他方式)来运行 shell 命令。这可能吗,因为这对我来说不是一个强大的领域。这是我使用 PuTTy 的过程。

  1. 登录到外壳
  2. cd 到 source/red5/dist
  3. 屏幕
  4. ./red5.sh
  5. CTRL-A 然后 D 分离
  6. 登出
4

6 回答 6

2

最简单的就是写一个shell脚本。然后通过 PHP 登录到远程控制台

  • shell_exec:执行一个shell命令并以字符串形式返回输出。
  • exec:只执行一个外部程序
于 2010-08-28T06:27:01.537 回答
2

实现您想要的一个简单方法是在屏幕中运行它:

while /bin/true ; do ./red5.sh ; done
于 2010-08-28T06:27:40.817 回答
1

PHP actually has a special operator for executing shell commands, the backtick:

`cd source/red5/dist`

will go to the specified directory. (But I don't know much about shell, so I can't implement you the whole thing.)

If you need much control over the execution (I don't know whether you need here) use proc_open.

于 2010-08-28T08:26:56.910 回答
1

如果您可以编写一个 shell 脚本来满足您的需求,那么 PHP 就拥有exec(),system()并且passthru()适合您。

于 2010-08-28T06:17:41.010 回答
0

您可以在 php 上使用玉米作业并将所有命令放在 .sh 文件中并像这样运行

59 11 * * 1,2,3,4,5 根命令文件.sh?token

像这样的东西,它将被保存

于 2010-08-28T06:19:25.937 回答
0

这里有不止一个好的答案,但您应该选择为 red5 执行 init 脚本而不是 .sh 或 .bat。这里有预制的初始化脚本: http://code.google.com/p/bigbluebutton/downloads/detail?name=red5&can=2&q=和这里:http : //www.videowhisper.com/forum.php? ftid=48&t=init-file-red5-linux-installations-red5-linux-init.d-chkconfig

于 2010-09-03T16:25:46.307 回答