Jump to content

Automatic Restart Scripts Linux?


Kr0zer

Recommended Posts

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

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

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

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

  • 6 months later...

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

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

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

  • 3 months later...

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

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

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
  • Discord

×
×
  • Create New...