Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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/

The remote script is /vol/

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 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/

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.

share|improve this question

1 Answer 1

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/

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, 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).

share|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 posting your answer, you agree to the privacy policy and terms of service.

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