#/bin/sh #all this only makes sense if the server is running if [[ $(pgrep java -U 1001) ]]; then #check if there is at least one player on the server and create a timestamp if (( $(/srv/telegraf-scripts/./mc-players.sh) > 0 )); then date +%s > /home/minecraft/scripts/lp_stamp fi #compare the last timestamp to the current time #if it is more than 14 days (i.e. 1209600 seconds) then shutdown the server #set the content of lp_shutdown, so the server knows not to auto restart if (( $(($(date +%s) - $(cat /home/minecraft/scripts/lp_stamp))) > 1209600 )); then echo "1" > /home/minecraft/scripts/lp_shutdown /srv/mcrcon-0.7.1-linux-x86-64/./mcrcon -p YiibUn8UzKBIQ52ZJu4P -w 2 "say Shutting down because the server was empty for 14 days" save-all stop > /dev/null 2>&1 fi fi