I currently have a script set to run every 6 hours (0000, 0600, 1200, 1800) that restarts a minecraft server running in a detached GNU screen.
I'd like to create a script that runs on the hour, that will show the remaining time to the next restart.
I.E.: After a restart, every hour the script will send the time remaining to the screen session, which will interpret and print it to the server.
Currently the hourly script looks like this, but I have a feeling i'll run into issues after 6PM:
HOUR=`echo $(($(date +%H) - 6))`
tleft=`echo $((12 % $HOUR))`
screen -X setenv remain "$tleft"
screen -X readbuf $remain
screen -x minecraft -X eval 'stuff "say The Server will restart in $remain hours"\015'
screen -x minecraft -X eval 'stuff "save-all"\015'
Any help is appreciated, thanks