Skip to main content
start.sh is the process that actually runs inside the tmux session. Its primary job is to run the Minecraft server and automatically restart it if it crashes — unless the shutdown was intentional.
You do not normally invoke start.sh directly. Use serv start instead, which sets up the tmux session, exports the necessary environment variables, and runs start.sh inside it.

How the loop works

The script registers a SIGINT/SIGTERM signal trap and runs in a while loop that continues as long as a keep_running flag is true. Each iteration of the loop:
  1. Checks for a stop_signal file before launching. If found, sets keep_running=false and removes the file — server does not start.
  2. Launches the Java process and blocks until it exits.
  3. Checks for stop_signal again immediately after the process exits.
  4. If keep_running is still true, waits 5 seconds, checks stop_signal one final time, then restarts.

The stop_signal file

The stop_signal file is the mechanism that differentiates an intentional stop from a crash. The script also traps SIGINT and SIGTERM — pressing Ctrl+C inside the tmux session sets keep_running=false without needing the file. This means a crash at any time — including during a snapshot window — will trigger an automatic restart within 5 seconds, unless serv stop was called first.

JVM flags

The server is launched with the following JVM arguments: The jar is launched with the nogui flag, which disables the Swing GUI that would otherwise fail in a headless environment.

tmux session details

The socket is created with permissions 770 after the session is started, so users in the owning group can attach without root.

Graceful stop vs crash

Graceful stop via serv stop:
Crash recovery:
The loop will then re-execute the java command and the server comes back up automatically. The tmux session and the loop itself remain alive throughout, so serv console continues to work even between restarts.