Skip to content

Linux script auto restarts MinecraftClient at time interval

MousePak edited this page Oct 17, 2022 · 1 revision

Keeping an account active would be the goal but due to networking or server restarts you may be kicked or disconnected for a range of reasons. Not every type of disconnect would be caught by autorelog so the following script would put your MinecraftClient into a loop which restarts at a defined frequency.

The three sections :

  1. Kill any old processes found to ensure you do not spawn zombie processes
  2. A method allowing semi clean breakout, without this the next section restarts preventing user breakout.
  3. Never ending loop every 6 hours which stops and restarting the process

Linux bash script running mono

for pid in $(ps -auxf | grep "timeout" | grep "player.ini" | awk '{print $3}'); do kill -9 $pid; done


trap printout SIGINT
printout() {
   echo "exiting"
   exit
}


while :
do
  timeout --foreground 6h mono MinecraftClient.exe player.ini
done