Here is a small shell script I wrote to autoupdate my linux csgo servers, you just need to modify it a bit with the correct paths. I have it running in cron every 5 minutes:
Code:
/5 * * * * /path/to/autoupdate.sh > /dev/null 2>&1
Code:
#!/bin/bash
DATE=$(date '+%Y_%m_%d_%H_%M')
CSLOG="/home/csgoserver/serverfiles/csgo/console.log" # path to your console.log file
STRING=$(grep -c "Your server is out of date and will be shutdown during" ${CSLOG})
if [ ${STRING} != 0 ]
then
/path/to/killserver.sh # change this to whatever command or script you use to kill your server (pkill screen, tmux etc)
# compress and remove the console.log file to prevent the script from falsely detecting an update
tar -czf console-${DATE}.tar.gz ${CSLOG} && rm ${CSLOG}
# update the server
/path/to/steamcmd.sh +login anonymous +force_install_dir /home/csgoserver/serverfiles/ +app_update 740 +quit
# restart the server
/path/to/startserver.sh
fi