I have a local script that runs a remote script via ssh. The local script is minecraft.php:

ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {$this->pemkey} {$this->ssh_user} sudo /vol/start_bukkit.sh

The remote script is /vol/start_bukkit.sh:

cd "/vol/bukkit"
/usr/bin/screen -S bukkit -m -d /usr/local/bin/java -Xnoclassgc -Xms1024M -Xmx1024M -jar /vol/bukkit/craftbukkit.jar nogui

What happens is that the java command works, launching craftbukkit.jar, but screen doesn't launch a new window. What's going on? How can a new window be created?

If I sign in to the remote server and run start_bukkit.sh then screen works as expected, creating a newly detached window running craftbukkit.jar in it.


I got it to work. I updated the local script by removing the sudo and putting the screen command in. Here it is:

ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {$this->pemkey} {$this->ssh_user} /usr/bin/screen -S bukkit -m -d /vol/start_bukkit.sh

On the remote side I removed the screen command:

cd "/vol/bukkit"
/usr/local/bin/java -Xnoclassgc -Xms1024M -Xmx1024M -jar /vol/bukkit/craftbukkit.jar nogui

I can't explain why this works.


Try forcing a psuedo-tty with your ssh command.

ssh -t -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i
{$this->pemkey} {$this->ssh_user} sudo /vol/start_bukkit.sh

man 1 ssh

     -t      Force pseudo-tty allocation.  This can be used to execute
             arbitrary screen-based programs on a remote machine, which 
             can be very useful, e.g. when implementing menu services.  
             Multiple -t options force tty allocation, even if ssh has 
             no local tty.

Also, in your script start_bukkit.sh, you don't have a PATH set. You call java without an absolute path, so it may not be found. Either set a PATH at the beginning of the script (best practice), or call java via the absolute path (/usr/bin/java).

| improve this answer | |
  • If I add ssh -t option then the screen window is not created AND the java program is not started. – PaulS Jun 26 '12 at 17:49
  • BTW, I updated java to the absolute path. – PaulS Jun 26 '12 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.