Kr0zer Posted February 27, 2014 Report Share Posted February 27, 2014 Hello, Just wondering if anyone has a automatic restart script for a Linux server running epoch 1.0.4.2. I have searched google countlessly and have found nothing. So I have taken to the forums to ask if there is a script in perl or other Linux Scripting languages to suit my needs. Thanks, Kr0zer. Link to comment Share on other sites More sharing options...
Metro Posted February 28, 2014 Report Share Posted February 28, 2014 Cron restarter.pl. Link to comment Share on other sites More sharing options...
DeanReid Posted February 28, 2014 Report Share Posted February 28, 2014 if you have access to cron for 3 hour restarts 0 0,3,6,9,12,15,18,21 * * * cd / && /home/dayzservers/epochchernarus/restarter.pl ignore the whole 0,3,6,9 I added mine through Webmin, so it sets it every 3 hours but just change /home/dayzservers to your location Link to comment Share on other sites More sharing options...
Guest Guest Posted February 28, 2014 Report Share Posted February 28, 2014 The CRON works (sort of) but would it be possible yo run it as a root user? The restarter file is run but not everything in the file works as it requires sudo permission. Any advice? Thanks Link to comment Share on other sites More sharing options...
Kr0zer Posted February 28, 2014 Author Report Share Posted February 28, 2014 The CRON works (sort of) but would it be possible yo run it as a root user? The restarter file is run but not everything in the file works as it requires sudo permission. Any advice? Thanks Link to comment Share on other sites More sharing options...
DeanReid Posted February 28, 2014 Report Share Posted February 28, 2014 if you are running as root *not recommended* make sure you do cd / && /home/dayzservers/epochchernarus/restarter.pl that will change to the / directory so it doesn't come up with the whole cant find binary stuff, then it will go to the location of your restarter file remember to actually change the location though :P or you could try doing cd / && sudo /home/dayzservers/epochchernarus/restarter.pl never tried it that way though Link to comment Share on other sites More sharing options...
2kohm Posted September 2, 2014 Report Share Posted September 2, 2014 cd /path/to/epoch/ && sudo ./restarter.pl works for me with crontab Link to comment Share on other sites More sharing options...
AlbertusSmythe Posted September 2, 2014 Report Share Posted September 2, 2014 I have a shell script that stops the running instance using the data in the .pid file and restarting the server from scratch. This script makes sure the directory is correct and has the option to stop and not restart. The reason I do this is because of the way Linux doesn't actually delete files until the last program using it closes the file, this causes (in my experience at least) the server to keep using use old "deleted" .pbo files instead of any new ones copied over and allows me to rotate the logs properly so that each restart has clean log files. Why are you having problems running restarter.pl as EpochServerUser ?, do you have some files owned by root? if so chown everything in your server folder to EpochServerUser (substitute your own user id) Link to comment Share on other sites More sharing options...
jahangir13 Posted September 2, 2014 Report Share Posted September 2, 2014 If you use an absolute path in restarter.pl (instead of this relative path in the original file) it works from everywhere without 'cd /path/to/epoch'. But ok, there is not much advantage in that ;) Link to comment Share on other sites More sharing options...
jahangir13 Posted September 2, 2014 Report Share Posted September 2, 2014 AlbertusSmythe: restarter.pl does also kill the process completely? my $res = `kill -TERM $pid 2>&1`; So why using an additional script. You can also put your backup/logrotate mechanism directly into restarter.pl. And this is not a Linux way problem. Any OS should take care of not deleting open files ;) Link to comment Share on other sites More sharing options...
AlbertusSmythe Posted September 3, 2014 Report Share Posted September 3, 2014 AlbertusSmythe: restarter.pl does also kill the process completely? my $res = `kill -TERM $pid 2>&1`; So why using an additional script. You can also put your backup/logrotate mechanism directly into restarter.pl. And this is not a Linux way problem. Any OS should take care of not deleting open files ;) I think that early on I was having problems with old mission PBOs being used even after being overwritten by new ones I assumed that restarter.pl wasn't releasing the old file handles so the old files were still being used rather than the new ones. After all Linux allows you to delete an open file but keeps a "ghost" copy for processes that are using it until all the open handles are closed. Also it's much easier for me to have a script called server in ~/bin and type server sauerland start than cd ~/server/sauerland && ./restarter.pl && cd - especially as I also have a test and a Napf server so server napf start & server test start also become easier to remember/type. Stopping a server becomes as simple as server sauerland stop, I don't have to faff about trying to find the correct pid to kill, as for adding the logrotate to restarter.pl, the less I can customise important files the easier it is to apply updates. Not terribly important but just the way I prefer to do things Link to comment Share on other sites More sharing options...
jahangir13 Posted September 3, 2014 Report Share Posted September 3, 2014 ;) Yes, that's a matter of opinion, I guess. The good thing there is that you keep the original files as they've been released. Should also think about something like this instead of copying my own code each into e.g. restarter.pl each time a new version is released. Link to comment Share on other sites More sharing options...
*OCB* Trollspace Posted September 3, 2014 Report Share Posted September 3, 2014 Do not use kill -TERM, use kill -SIGINT. Otherwise the server will not perform shutdown, flush the output and notify the clients about disconnection, which is likely the reason why player stuff isn't saved in the last minutes before the server. Link to comment Share on other sites More sharing options...
LunchboxCharlie Posted December 19, 2014 Report Share Posted December 19, 2014 I can't find the location of these php scripts, I saw them about 2-3 days ago. Link to comment Share on other sites More sharing options...
jahangir13 Posted December 19, 2014 Report Share Posted December 19, 2014 My friend DeanReid has them still there: https://github.com/deannreid/BattlEye-RCON-Control-PHP/ Link to comment Share on other sites More sharing options...
LunchboxCharlie Posted December 20, 2014 Report Share Posted December 20, 2014 I got a little creative when setting up the scripts figured I would show you them as a mini example if people want to break it down into seconds. 10,30,50 0-1 * * * php -q /root/servers/epoch/restart/resinf.php #Restart Information 0 1,5,9,13,17,21 * * * php -q /root/servers/epoch/restart/3hr.php #3 Hour Restart Warning 0 2,6,10,14,18,22 * * * php -q /root/servers/epoch/restart/2hr.php #2 Hour Restart Warning 0 3,7,11,15,19,23 * * * php -q /root/servers/epoch/restart/1hr.php #1 Hour Restart 30 3,7,11,15,19,23 * * * php -q /root/servers/epoch/restart/30min.php #30 Min Restart 45 3,7,11,15,19,23 * * * php -q /root/servers/epoch/restart/15min.php #15 Min Restart 50 3,7,11,15,19,23 * * * php -q /root/servers/epoch/restart/10min.php #10 Min Restart 55 3,7,11,15,19,23 * * * php -q /root/servers/epoch/restart/5min.php #5 Min Restart 58 3,7,11,15,19,23 * * * php -q /root/servers/epoch/restart/2min.php #2 Min Restart 59 3,7,11,15,19,23 * * * php -q /root/servers/epoch/restart/1min.php #1 Min Restart 59 3,7,11,15,19,23 * * * (sleep 30 && php -q /root/servers/epoch/restart/30sec.php) #30 Seconcd Restart 59 3,7,11,15,19,23 * * * (sleep 40 && php -q /root/servers/epoch/restart/20sec.php) #20 Seconcd Restart 59 3,7,11,15,19,23 * * * (sleep 50 && php -q /root/servers/epoch/restart/10sec.php) #10 Seconcd Restart 59 3,7,11,15,19,23 * * * (sleep 51 && php -q /root/servers/epoch/restart/9sec.php) #9 Seconcd Restart 59 3,7,11,15,19,23 * * * (sleep 52 && php -q /root/servers/epoch/restart/8sec.php) #8 Seconcd Restart 59 3,7,11,15,19,23 * * * (sleep 53 && php -q /root/servers/epoch/restart/7sec.php) #7 Seconcd Restart 59 3,7,11,15,19,23 * * * (sleep 54 && php -q /root/servers/epoch/restart/6sec.php) #6 Seconcd Restart 59 3,7,11,15,19,23 * * * (sleep 55 && php -q /root/servers/epoch/restart/5sec.php) #5 Seconcd Restart 59 3,7,11,15,19,23 * * * (sleep 56 && php -q /root/servers/epoch/restart/4sec.php) #4 Seconcd Restart 59 3,7,11,15,19,23 * * * (sleep 57 && php -q /root/servers/epoch/restart/3sec.php) #3 Seconcd Restart 59 3,7,11,15,19,23 * * * (sleep 58 && php -q /root/servers/epoch/restart/2sec.php) #2 Seconcd Restart 59 3,7,11,15,19,23 * * * (sleep 59 && php -q /root/servers/epoch/restart/1sec.php) #1 Seconcd Restart 59 0,4,8,12,16,20 * * * php -q /root/servers/epoch/restart/restart.php #Restart Link to comment Share on other sites More sharing options...
LunchboxCharlie Posted December 20, 2014 Report Share Posted December 20, 2014 Yeah yeah yeah, don't run as root. DeanReid 1 Link to comment Share on other sites More sharing options...
jahangir13 Posted December 20, 2014 Report Share Posted December 20, 2014 The problem is not only security (using user root)...it's more likely that you enter something wrong and there is no 'Do you really want to do that' message when pressing enter. A few weeks ago I've changed owner permissions of my complete /var directory accidentially (chown -R /var instead of chown -R var). Errors (even without stupidity) happen but you do not want to fix such a kind of hassle afterwards ;) Consider iIf you run rm -rf / home/user/subdir as root...(there is 1 space too much). Any small bug in the application (and I guess there are at least some in every application possibly) can delete or change system files which would not happen for running the server as a normal user or at least you would get warned for entering a super user password. Commands executed with sudo are (as far as I know) logged...so you can diagnose problems if something has been done wrong. root user can hide all executed commands. http://askubuntu.com/questions/16178/why-is-it-bad-to-login-as-root Link to comment Share on other sites More sharing options...
Mochan Posted December 25, 2014 Report Share Posted December 25, 2014 Can someone explain how to set this up? I'm kinda confused about the whole cRON stuff? Link to comment Share on other sites More sharing options...
DeanReid Posted December 25, 2014 Report Share Posted December 25, 2014 What OS do you run? and do you have any panel installed? Link to comment Share on other sites More sharing options...
Mochan Posted December 26, 2014 Report Share Posted December 26, 2014 What OS do you run? and do you have any panel installed? Ubuntu 12.04 & By panels you mean things like webmin? If so yes I am running webmin. Link to comment Share on other sites More sharing options...
DeanReid Posted December 26, 2014 Report Share Posted December 26, 2014 then you can use this as a tutorial :) https://github.com/deannreid/BattlEye-RCON-Control-PHP#for-webmin Link to comment Share on other sites More sharing options...
Mochan Posted December 26, 2014 Report Share Posted December 26, 2014 then you can use this as a tutorial :) https://github.com/deannreid/BattlEye-RCON-Control-PHP#for-webmin okay, got these setup in my webmin, do these also restart the server or? Link to comment Share on other sites More sharing options...
DeanReid Posted December 26, 2014 Report Share Posted December 26, 2014 if you set it to the restarter.pl then yes :) Link to comment Share on other sites More sharing options...
Mochan Posted December 26, 2014 Report Share Posted December 26, 2014 if you set it to the restarter.pl then yes :) So create another webmin script that will execute restarter.pl just like I did there? Link to comment Share on other sites More sharing options...