Skip to content

Instantly share code, notes, and snippets.

@gkhays
Created June 17, 2014 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gkhays/edf3054d37fb43dfb743 to your computer and use it in GitHub Desktop.
Save gkhays/edf3054d37fb43dfb743 to your computer and use it in GitHub Desktop.
Run Minecraft Server as a Daemon
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