Java Reference
In-Depth Information
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. 5 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” error.)
That will start the server off in its own little world, which won't be affected
by you logging off. If you want to “attach” to the server so you can issue
commands and such, use screen with the -r option and the session name:
$ screen -r mcserver
And you'll be attached to the server with the usual spew and prompt:
16:47:49 [INFO] Done (1.163s)! For help, type "help" or "?"
>
To detach from your server session, press Ctrl - a then d . You'll be returned to
your original shell, and your server will still be running in the background.
To see what processes you have running, use the ps command:
Server ~$ ps
PID TTY
TIME CMD
337 ttys000
0:00.09 -bash
842 ttys020
0:13.78 /usr/bin/java -jar CanaryMod.jar
And to see all the processes on a machine, try psax . ( ps-? will list the options.)
In a pinch, if you need to kill off all Java processes, you can use
Server ~$ killall java
That asks Java to do some cleanup and exit in a safe and reliable manner.
However, if it's stubborn and won't behave, you can use the brutal
5.
There's a slightly simpler way to do this using the command nohup (named for “No
Hangup”); however, you lose the ability to enter commands to the server easily.
 
 
 
Search WWH ::




Custom Search