Running Remotely

There’s a slight hitch with running a script like start_minecraft when you’re logged in via ssh. As soon as you log out, the script will be killed. That’s not very helpful in a server environment.

Fortunately, you can use a command named screen to keep Java running even though you’ve logged out.[53] It takes an argument string of -d -m -S followed by a name for your server session. We’ll use mcserver to name the session, so the new server-style startup script will look like this:

 
#!/bin/bash
 
cd​ ​"$( dirname "​$0​" )"
 
screen -d -m -S mcserver java -Xms1024M -Xmx1024M -jar CanaryMod.jar --noControl

(Remember, start_minecraft needs to be executable; be sure to do a chmod +x start_minecraft if you get a “permission denied” ...

Get Learn to Program with Minecraft Plugins, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.