For this script to work you need a “version.txt” file in the same folder as the script. The file has to contain your current server version(1.12.1).

NEWVERSION=$(curl -s 'https://launchermeta.mojang.com/mc/game/version_manifest.json' | python3 -c "import sys, json; print(json.load(sys.stdin)['latest']['release'])")
    if [ $NEWVERSION != $(cat version.txt) ]; then
       echo $NEWVERSION > version.txt
       wget 'https://s3.amazonaws.com/Minecraft.Download/versions/'$NEWVERSION'/minecraft_server.'$NEWVERSION'.jar'
       ps aux | grep -i minecraft_server | awk {'print $2'} | xargs kill -9
       nohup java -Xmx1324M -Xms1324M -jar 'minecraft_server.'$NEWVERSION'.jar' &
fi
⤧  Previous post Send Emails from the Command-line