Created
June 17, 2014 15:04
-
-
Save gkhays/edf3054d37fb43dfb743 to your computer and use it in GitHub Desktop.
Run Minecraft Server as a Daemon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I liked this one the best: http://www.minecraftforum.net/topic/74402-setup-linux-daemon/. | |
1) Get the code snippet below into a file in /etc/init.d/. This will be referenced as FILENAME henceforth. I used: | |
/etc/init.d/minecraft-server: | |
minecraft-server | |
#! /bin/sh | |
# | |
# network Bring up/down networking | |
# | |
# chkconfig: 345 20 80 | |
# description: Starts and stops minecraft-server-nogui.sh | |
# | |
case "$1" in | |
start) | |
echo -n "Starting Minecraft Server" | |
/bin/su - andrew -c '/opt/minecraft_server/minecraft-server-start-nogui.sh' | |
echo "." | |
;; | |
stop) | |
echo -n "Stopping Minecraft Server" | |
kill `ps auxw | grep minecraft.jar | awk '{print $2}'` | |
echo "." | |
;; | |
*) | |
echo "Usage: /sbin/service minecraft-server {start|stop}" | |
exit 1 | |
esac | |
2) chmod a+x FILENAME | |
3) chkconfig --add FILENAME | |
4) chkconfig |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment