Tutorials/Server startup script

This is an example of possible Minecraft server startup and maintenance script for GNU/Linux distros.

Pre-Requisites
Screen package must be installed. On Red Hat-based distributions: yum install screen On Debian based systems such as Ubuntu: apt-get install screen

Download
To download the script with wget, run the following (WATCH OUT SCRIPT NEEDS WORK): wget -O minecraft "http://www.minecraftwiki.net/Server_startup_script/Script?action=raw"

Requirements

 * screen

Installation
Use your favorite editor to create file called minecraft in /etc/init.d/ and paste the script above in that file.

Edit the USERNAME and MCPATH -variables according to your setup. If you use a wrapper script, change INVOCATION to start it instead of starting the server directly.

Make sure the newly created file has required permissions You can set the permissions by running: chmod a+x /etc/init.d/minecraft

Then run (on Debian-based distributions) update-rc.d minecraft defaults to add required symbolic links. Note: your system will most likely warn you that the script does not meet all requirements. The script will however work.

You can also setup an entry in your crontab to backup the server with: /etc/init.d/minecraft backup

A sample crontab to backup every half hour on the hour, and 30 minutes into the hour:

crontab -e and add this 0,30 * * * * /etc/init.d/minecraft backup
 * Using the user account you want the work done under, run:

If the above attempt went poorly because you do not know how to use vi, try: VISUAL=/usr/bin/nano crontab -e

Uninstall
(In debian based GNU/Linux distribution) update-rc.d -f minecraft remove

Usage
The script may be invoked via the following command on most systems, where "(command)" will be "stop", "start", "restart", or any of the other options it supports. /etc/init.d/minecraft (command) On most RedHat- or Debian-based distribution where the `service` command is available, it should be invoked as: service minecraft (command) To view the screen, use: screen -r

To exit the screen, use: CTRL+a+d

Extra information
If you still want to view the live log file, use this command in the server directory. tail -f server.log

Alternative Startup Scripts
The following scripts offer the same functions as the above script but contain more useful features:
 * Minecraft Server Manager An improvement of this script with comprehensive features and multi-server support.
 * Features include "super responsive" commands return as soon as possible, minimising player down time.
 * Keeps players informed with configurable in-game messages, such as "Shutting down in 10 seconds!"
 * Periodical WorldEdit compatible world backups.
 * Load worlds into RAM for fast access reducing lag.
 * Tab completion on all commands makes learning easy.
 * Visit Minecraft Server Manager's GitHub page for the full list of features.
 * mcwrapper
 * [Multi World] GNU/Linux Minecraft server control script
 * MC Sheller
 * minecraft init (modification of this script with a lot more features like multiworld)
 * Dagmar d'Surreal's Sysv init script
 * Setsuna-Xero's OpenRC(Gentoo) compatible init script, with conf.d defaults
 * Mineserv Perl Init Script
 * A very simple automatic start/stop script with backup and cleanup functions and the ability to pass commands to the server console.