trq Posted January 3, 2008 Share Posted January 3, 2008 You won't need to kill it as root, root didn't start the process. Something like.... <?php exec('kill -9 $(ps -C server-bin | grep server-bin | awk "{print $1}")'); ?> should go pretty close providing theres only one instance running. Quote Link to comment https://forums.phpfreaks.com/topic/84178-solved-system-command/page/2/#findComment-429047 Share on other sites More sharing options...
AV1611 Posted January 3, 2008 Author Share Posted January 3, 2008 That worked just as expected. I've got 2 final minor problems. 1. When I issue the exec() to start the server, it starts perfectly but the browser never gets any info so it sits with an hourglass and never times out or whatever. You can close the browser ok, but that's kinda annoying. Suggestions? I put an echo success at the end of the clause but it never get's to it. Suggestions? 2. The stop worked flawlessly. I need to modify that to some kind of check to see if the server is already started before trying to start it... I can handle the clauses, I just could use some help with the $var made from the exec() to see if it is running already. Hope that makes sense. Quote Link to comment https://forums.phpfreaks.com/topic/84178-solved-system-command/page/2/#findComment-429701 Share on other sites More sharing options...
AV1611 Posted January 3, 2008 Author Share Posted January 3, 2008 BTW <?php if(!isset($_GET['run'])) { echo' <a href="server3.php?run=start">Start Game Server</a><br /> <a href="server3.php?run=stop">Stop Game Server</a><br /> '; die('You must specify an option'); } if($_GET['run']=="start") { set_time_limit(3); //<--- did not help chdir('/home/aops-lnxded-2.8.1/System'); exec('/home/aops-lnxded-2.8.1/System/server-bin GLOBAL sniper_range.aao -nohomedir ini=server.ini &'); echo 'Server Started...'; //<--- never get here } elseif($_GET['run']=="stop") { exec('kill -9 $(ps -C server-bin | grep server-bin | awk "{print $1}")'); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/84178-solved-system-command/page/2/#findComment-429706 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.