>I am writing a control panel for a gamehost using PHP, which calls a bash >script (which wraps around another) to control game servers > >Right now once the bash scripts are running the PHP script that called >them is unavailable for any more users, and if apache is restarted the >bash script is killed
You may want to investigate the (currently) experimental PCNTL extension in PHP - it provides support for forking, which is the usual way to handle daemons like this. Another option is to simply write a daemon, and pass commands to it via a socket or spawn new instances upon request. This should be fairly easy using Perl, and it allows you to decouple your webserver from the inner workings of your game host, and have leaner forked processes (no need to have the full overhead of an apache child process to run a game host, I assume). >Here's the code so far: > >[the php file] > >case "start": exec('bash -c "exec nohup ./run2 > /dev/null 2>&1 &"'); I think the trivial fix here is to stick that last '&' outside the '"', so that the bash process drops into the background. --------------------------------------------------------------------- michal migurski- contact info and pgp key: sf/ca http://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php