A lightweight Go script for managing Minecraft server sessions inside tmux — automatically restarts the server when it stops, logs exit codes, and allows graceful shutdowns.
- Automatically starts a Minecraft server in a tmux session
- Prevents multiple sessions with the same name
- Auto-restarts the server after crashes
- Allows you to stop restarts by pressing Enter within a configurable wait time
- Logs all exit codes to
exit_codes/server_exit_codes.log - Configurable RAM usage, wait time, and JAR file
- Go 1.21+ (to build)
- tmux installed
- Java (for running the Minecraft server)
-
Clone or download this repository:
git clone git@github.com:Eposs10/tmux-mc-server-starter.git cd tmux-mc-server-starter -
Build the executable:
go build -o mc-tmux
-
Move it somewhere in your
$PATH(optional):sudo mv mc-tmux /usr/local/bin/
mc-tmux <session_name> <path> [options]| Option | Type | Default | Description |
|---|---|---|---|
--jar |
string |
server.jar |
The Minecraft server JAR file to run |
--min-ram |
string |
2G |
Minimum RAM allocation |
--max-ram |
string |
6G |
Maximum RAM allocation |
--wait-time |
int |
5 |
Seconds to wait before restarting |
If a session with the same name already exists, the script will automatically attach to it instead of creating a new one:
⚠️ Session 'survival' already exists — attaching instead.
mc-tmux survival /home/minecraft/server --max-ram 8G --min-ram 4G --wait-time 10This starts a new tmux session named survival, running the server at /home/minecraft/server with 4–8 GB of RAM.
If the server crashes or stops, it will wait 10 seconds before restarting — unless you press Enter.
To attach to an existin session use the tmux command
tmux a -t <session_name>Exit codes are saved under:
exit_codes/server_exit_codes.log
Each entry includes a timestamp and the exit code.
To stop the automatic restart loop:
- Stop the server normally (e.g.,
stopcommand in Minecraft console). - When prompted:
Press Enter before the timer runs out.
----- Press enter to prevent the server from restarting in 5 seconds -----