tags:

views:

90

answers:

6

Occasionally my media server goes down and I'm wondering if it's possible to start it remotely using php to check the port and if it's not running invoke cron (or some other way) to run a shell command. Is this possible because this is not a strong area for me. Here's the process I use with PuTTy.

  1. login to shell
  2. cd to source/red5/dist
  3. screen
  4. ./red5.sh
  5. CTRL-A then D to detach
  6. logout
+1  A: 

If you can write a shell script that does what you need, then PHP's has exec(), system() and passthru() for you.

tdammers
A: 

you can use corn job on php and put all command on .sh file and run like this

59 11 * * 1,2,3,4,5 root command file.sh?token

something like this ,it will be save

JapanPro
A: 

Simplest thing is to write a shell script. And then login to remote console via PHP.

  • shell_exec: execute a shell command and returns the output as string.
  • exec: just executes an external program
Ankit Jain
+1  A: 

A simple way to achieve what you want is to run this in screen:

while /bin/true ; do ./red5.sh ; done
jmz
A: 

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.

nikic
A: 

There is more than one good answer here, but you should opt for executing the init script for red5 instead of the .sh or .bat. There are pre-made init scripts here: http://code.google.com/p/bigbluebutton/downloads/detail?name=red5&can=2&q= and here: http://www.videowhisper.com/forum.php?ftid=48&t=init-file-red5-linux-installations-red5-linux-init.d-chkconfig

Mondain