framework/script/alivecheck.sh
2022-04-09 14:37:24 +03:00

20 lines
422 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
else
# Server is still running, reset the crash loop detector
rm ~/server/server_stops.log
fi
done