Jump to content

Proper restart-script for server


Dr_Cox1911

Recommended Posts

I´m currently trying to enhance the performance of my server and therefore need some help.

 

With build28 we can directly manage the server with console-commands, so it should be possible to do a grace restart.

 

Some time ago I used a script which will simply kill the process and restart the sh-script, but I deactivated it because of potential damage to the map/save. I have decent linux skills but I´m kinda stuck here.

 

What I would like to achieve with the restart-script:

  • 5min before restart send a message to all players
  • send the "quit"-command to the server
  • wait a couple of minutes
  • restart the server

I´m stuck at the communication from my script to the actual game-server. Hope there are some Linux-cracks around here (looking at you Kirrus  ;-) )

Link to comment
Share on other sites

I assume the script you talk about is mine perhaps and you're completely right. I don't know if direct server interaction through the console has been introduced yet, or if it's still on the horizon (I'm a bit out of date with some MP features right now) but if it's not, then I think this would be quite a difficult thing, short of some sort of script that has a dummy player admin on the server with which the server communicates with to execute the commands needed. (Think that's what minecraft, some arma servers do for example)

 

However if there is RCON support, if the script was set up as a CRON job or something, then at the start of the script you broadcast a message, then run something like sleep in the script for 5 minutes, then execute the rest of the script then I suppose that would work as well.

 

Probably not an answer you're looking for, but I thought I would shed some light on it all the same.

Link to comment
Share on other sites

 

I heard through the grapevine that in Build 28 admin commands can be entered into the server console. Haven't verified it though.

 

Yes, they can be.

 

 

In which case it would be as simple as having the bash script run a command through screen (if that's how the server's set up.)

 

Edit: If interested, I might mock something up.

Link to comment
Share on other sites

  • 3 months later...

start server

screen -S prz_zombi ./servers/projectzomboid/projectzomboid-dedi-server.sh

 

cron

* */3 * * * /root/zomboid_restart.sh

 

 

zomboid_restart.sh

 

#!/bin/bash
 
screen -rd prz_zombi
screen -S prz_zombi -X stuff 'servermsg restart after 1 min\r'
sleep 45s
screen -S prz_zombi -X stuff 'save\r'
screen -S prz_zombi -X stuff 'Please disconnect for 30 sec\r'
sleep 5s
 
DATE=`date +%Y-%m-%d_%H-%M-%S`
DIR=/root/backups/zomboid
mkdir backups
mkdir $DIR
cd $DIR 
 
# create backup
tar -czf configs_$DATE.tar.gz -P /root/Zomboid /root/servers/projectzomboid/media/lua/shared/Sandbox
 
# delete old backup
find $DIR -name "*.gz" -mtime 2 -exec rm -f {} \;
 
screen -S prz_zombi -X stuff 'servermsg restart after 10 sec\r'
sleep 5s
screen -S prz_zombi -X stuff 'servermsg 5 sec\r'
sleep 1s
screen -S prz_zombi -X stuff 'servermsg 4 sec\r'
sleep 1s
screen -S prz_zombi -X stuff 'servermsg 3 sec\r'
sleep 1s 
screen -S prz_zombi -X stuff 'servermsg 2 sec\r'
sleep 1s
screen -S prz_zombi -X stuff 'servermsg 1 sec\r'
sleep 1s
screen -S prz_zombi -X stuff 'servermsg RESTART\r'
sleep 1s
screen -X -S prz_zombi quit
screen -wipe
sleep 5s
 
# restart
/usr/bin/screen -dmS prz_zombi /root/servers/projectzomboid/projectzomboid-dedi-server.sh
 
 
Use :)
Link to comment
Share on other sites

  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...