Skip to content

Eposs10/tmux-mc-server-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minecraft Server Tmux Manager

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.

Features

  • 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

Requirements

  • Go 1.21+ (to build)
  • tmux installed
  • Java (for running the Minecraft server)

Installation

  1. Clone or download this repository:

    git clone git@github.com:Eposs10/tmux-mc-server-starter.git
    cd tmux-mc-server-starter
  2. Build the executable:

    go build -o mc-tmux
  3. Move it somewhere in your $PATH (optional):

    sudo mv mc-tmux /usr/local/bin/

Usage

Basic Command

mc-tmux <session_name> <path> [options]

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

Existing Session

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.

Example

mc-tmux survival /home/minecraft/server --max-ram 8G --min-ram 4G --wait-time 10

This 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.

Attaching to an existing session

To attach to an existin session use the tmux command

tmux a -t <session_name>

Logs

Exit codes are saved under:

exit_codes/server_exit_codes.log

Each entry includes a timestamp and the exit code.

Stopping the Server

To stop the automatic restart loop:

  1. Stop the server normally (e.g., stop command in Minecraft console).
  2. When prompted:
    ----- Press enter to prevent the server from restarting in 5 seconds -----
    
    Press Enter before the timer runs out.

About

A lightweight Go script for managing Minecraft server sessions inside tmux.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages