dabip Posted June 22, 2009 Share Posted June 22, 2009 Hello, I'm trying to SSH into a remote Debian Linux Server, and run a server. The server download is at: http://download.mtasa.com/deathmatch.html in case you wanted to test it out Anyway, here is the code I'm using: My SSH Class built on top of SSH2 http://dabphp.pastebin.com/m1c5563 My Code utilizing it... http://dabphp.pastebin.com/m2c0acf34 I have tried using nohup, and ./mta_server & and other things through PHP and it just won't stay running. I can run it, and keep it running in Terminal, but it just won't work in PHP. I can run things like apache(2), and other things that auto-fork into the background, just nothing that simply runs right where it's created. I hope I've included everything. This problem has been racking my brain for days now and it's just got me frustrated.. Anywho, thanks for taking your time to help out a frustrated 'ol php coder Quote Link to comment Share on other sites More sharing options...
trq Posted June 22, 2009 Share Posted June 22, 2009 Change... echo $ssh -> cmdExec( 'cd /home/mtadm/11', 'nohup ./mta_server > /dev/null & echo $!' ); to echo $ssh -> cmdExec( 'cd /home/mtadm/11', 'nohup ./mta_server & > /dev/null'); Quote Link to comment Share on other sites More sharing options...
dabip Posted June 22, 2009 Author Share Posted June 22, 2009 Hmm that didn't seem to do anything either. I'm really thinking taht it's simply the process, and not our code. I even tried running a remote script on in the path of the ./mta_server file itself. <?php echo run_in_background( "./mta_server" ); $fh = fopen( 'test.txt', 'w' ); fwrite( $fh, 'Hi' ); fclose( $fh ); function run_in_background($Command, $Priority = 0) { if($Priority) $PID = shell_exec("nohup nice -n $Priority $Command 2> /dev/null & ech$ else $PID = shell_exec("nohup $Command 2> /dev/null & echo $!"); return($PID); } ?> It still failed to run into the background. :\ (I found that function on some website). It still wrote a file btw. So it was functioning correctly :\ Quote Link to comment Share on other sites More sharing options...
dabip Posted June 23, 2009 Author Share Posted June 23, 2009 Just a small bump. Noticed this was starting to fall down Quote Link to comment 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.