有时我的媒体服务器出现故障,我想知道是否可以使用 php 远程启动它来检查端口,以及它是否没有运行调用 cron(或其他方式)来运行 shell 命令。这可能吗,因为这对我来说不是一个强大的领域。这是我使用 PuTTy 的过程。
- 登录到外壳
- cd 到 source/red5/dist
- 屏幕
- ./red5.sh
- CTRL-A 然后 D 分离
- 登出
最简单的就是写一个shell脚本。然后通过 PHP 登录到远程控制台。
实现您想要的一个简单方法是在屏幕中运行它:
while /bin/true ; do ./red5.sh ; done
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.
如果您可以编写一个 shell 脚本来满足您的需求,那么 PHP 就拥有exec()
,system()
并且passthru()
适合您。
您可以在 php 上使用玉米作业并将所有命令放在 .sh 文件中并像这样运行
59 11 * * 1,2,3,4,5 根命令文件.sh?token
像这样的东西,它将被保存
这里有不止一个好的答案,但您应该选择为 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