framework/script/alivecheck.sh
2021-11-19 17:39:07 +02:00

18 lines
326 B
Bash
Executable file

#!/bin/sh
# The following script is a failsafe for killing the Minecraft server if it happens
# to be stuck
set -x
while true; do
sleep 420
# If the server doesn't respond to ping, kill it
if [ "$(env printf '\xFE' | nc -w 15 0.0.0.0 25565 | wc -m)" -eq 0 ]; then
pkill -9 java
echo $(date) >> ~/kill.log
fi
done