Jump to content
Kr0zer

Automatic Restart Scripts Linux?

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.

 

Share this post


Link to post
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 

Share this post


Link to post
Share on other sites
Guest Guest

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

Share this post


Link to post
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

 

 

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
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 ;)

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

;) 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.

Share this post


Link to post
Share on other sites

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


Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Similar Content

    • By tyrant50187
      Im looking for the ability to add Script allowing Eyescan (retina scan) For Safe's and lockboxes, ether or, its something i havent found any script for but have found mentions and seen, any suggestions, links, or scripts are welcome, please Let me know!
    • By Bloodthirsty
      Hey I just need some files for this server, any and all you guys can come up with and think it deserve post that shit in chat rn. I want to see some crazy ideas and additions if you got em :) Lets see what you guys can come up with

    • By randall421
      The loot spawning on my server will respawn or cycle right infrnt of you if you move more than 5m away or if someone else near you moves 5ft away. I check player_spawncheck.sqf and it looks fine. 
      player_spawncheck.sqf 
      //player_spawncheck.sqf private ["_isWreck","_maxControlledZombies","_looted","_zombied","_doNothing","_spawnZedRadius","_serverTime","_age","_nearbyBuildings","_position","_speed","_radius","_maxlocalspawned","_maxWeaponHolders","_currentWeaponHolders","_maxtoCreate","_inVehicle","_isAir","_isLand","_isSea","_Controlledzeddivided","_totalcrew","_nearby","_type","_config","_canSpawn","_dis","_checkLoot","_islocal","_bPos","_zombiesNum"]; _age = -1; //_nearbyBuildings = []; _position = [player] call fnc_getPos; _speed = speed (vehicle player); _radius = 200; //150*0.707; Pointless Processing (106.5) _spawnZedRadius = 20; /* //Tick Time PVDZ_getTickTime = player; publicVariableServer "PVDZ_getTickTime"; */ //Total Counts _maxlocalspawned = round(dayz_spawnZombies); _maxControlledZombies = round(dayz_maxLocalZombies); _maxWeaponHolders = round(dayz_maxMaxWeaponHolders); _currentWeaponHolders = round(dayz_currentWeaponHolders); //Limits (Land,Sea,Air) _inVehicle = (vehicle player != player); /* _isAir = vehicle player iskindof "Air"; _isLand = vehicle player iskindof "Land"; _isSea = vehicle player iskindof "Sea"; if (_isLand) then { } else { }; if (_isAir) then { } else { }; if (_isSea) then { } else { }; */ _doNothing = false; if (_inVehicle) then { _Controlledzeddivided = 0; //exit if too fast if (_speed > 25) exitwith {_doNothing = true;}; //Crew can spawn zeds. _totalcrew = count (crew (vehicle player)); if (_totalcrew > 1) then { _Controlledzeddivided = 2; //Dont allow driver to spawn if we have other crew members. if (player == driver (vehicle player)) exitwith {_doNothing = true;}; } else { _Controlledzeddivided = 4; }; if (_Controlledzeddivided > 0) then { _maxControlledZombies = round(_maxControlledZombies / _Controlledzeddivided); r_player_divideinvehicle = _Controlledzeddivided; }; }; if (_doNothing) exitwith {}; /*if ("ItemMap_Debug" in items player) then { deleteMarkerLocal "MaxZeds"; deleteMarkerLocal "Counter"; deleteMarkerLocal "Loot30"; deleteMarkerLocal "Loot120"; deleteMarkerLocal "Agro80"; _markerstr = createMarkerLocal ["MaxZeds", _position]; _markerstr setMarkerColorLocal "ColorYellow"; _markerstr setMarkerShapeLocal "ELLIPSE"; _markerstr setMarkerBrushLocal "Border"; _markerstr setMarkerSizeLocal [_radius, _radius]; _markerstr1 = createMarkerLocal ["Counter", _position]; _markerstr1 setMarkerColorLocal "ColorRed"; _markerstr1 setMarkerShapeLocal "ELLIPSE"; _markerstr1 setMarkerBrushLocal "Border"; _markerstr1 setMarkerSizeLocal [_radius+100, _radius+100]; _markerstr2 = createMarkerLocal ["Agro80", _position]; _markerstr2 setMarkerColorLocal "ColorRed"; _markerstr2 setMarkerShapeLocal "ELLIPSE"; _markerstr2 setMarkerBrushLocal "Border"; _markerstr2 setMarkerSizeLocal [80, 80]; _markerstr2 = createMarkerLocal ["Loot30", _position]; _markerstr2 setMarkerColorLocal "ColorRed"; _markerstr2 setMarkerShapeLocal "ELLIPSE"; _markerstr2 setMarkerBrushLocal "Border"; _markerstr2 setMarkerSizeLocal [30, 30]; _markerstr3 = createMarkerLocal ["Loot120", _position]; _markerstr3 setMarkerColorLocal "ColorBlue"; _markerstr3 setMarkerShapeLocal "ELLIPSE"; _markerstr3 setMarkerBrushLocal "Border"; _markerstr3 setMarkerSizeLocal [120, 120]; diag_log ("LocalZombies: " +str(dayz_spawnZombies) + "/" +str(dayz_maxLocalZombies)); //Logging diag_log (format["%1 Local.Agents: %2/%3, NearBy.Agents: %8/%9, Global.Agents: %6/%7, W.holders: %10/%11, (radius:%4m %5fps).","SpawnCheck", _maxlocalspawned, _maxControlledZombies, _radius, round diag_fpsmin,dayz_currentGlobalZombies, dayz_maxGlobalZeds, dayz_CurrentNearByZombies, dayz_maxNearByZombies, _currentWeaponHolders,_maxWeaponHolders]); };*/ // nearObjects is faster than nearestObjects when sorting by distance isn't needed // "Building" includes House and all of its child classes (Crashsite, IC_Fireplace1, IC_Tent, etc.) _nearby = _position nearObjects ["Building",_radius]; _maxlocalspawned = _maxlocalspawned max floor(_maxControlledZombies*.8); if (_maxlocalspawned > 0) then { _spawnZedRadius = _spawnZedRadius * 3; }; //Spawn Zeds & loot in buildings { _type = typeOf _x; _config = missionConfigFile >> "CfgLoot" >> "Buildings" >> _type; _canSpawn = isClass (_config); if (_canSpawn) then { _dis = _x distance player; _checkLoot = (count (getArray (_config >> "lootPos"))) > 0; _islocal = _x getVariable ["", false]; // object created locally via TownGenerator. //Make sure wrecks always spawn Zeds _isWreck = _x isKindOf "CrashSite"; //Loot if (getNumber(_config >> "lootChance") > 0) then { if (_currentWeaponHolders < _maxWeaponHolders) then { //Basic loot check if ((_dis < 125) and (_dis > 30) and !_inVehicle and _checkLoot) then { _serverTime = serverTime; _looted = (_x getVariable ["looted",_serverTime]); _age = _serverTime - _looted; //Building refresh rate if (_age == 0 or (_age > getNumber(_config >> "lootRefreshTimer"))) then { _x setVariable ["looted",_serverTime,!_islocal]; _x call building_spawnLoot; if (!(_x in dayz_buildingBubbleMonitor)) then { dayz_buildingBubbleMonitor set [count dayz_buildingBubbleMonitor, _x]; }; //diag_log [ diag_tickTime, "new loot at",_x,"age:", _age, "serverTime:", _serverTime]; }/* else { diag_log [ diag_tickTime, "won't spawn loot at",_x,"age:", _age, "serverTime:", _serverTime]; }*/; }; }; }; //Zeds if (getNumber(_config >> "zombieChance") > 0) then { if (_dis > _spawnZedRadius) then { _serverTime = serverTime; _zombied = (_x getVariable ["zombieSpawn",_serverTime]); _age = _serverTime - _zombied; if ((_age == 0) or (_age > 300)) then { if (!_isWreck) then { if ((dayz_spawnZombies < _maxControlledZombies) and (dayz_CurrentNearByZombies < dayz_maxNearByZombies) and (dayz_currentGlobalZombies < dayz_maxGlobalZeds)) then { _bPos = getPosATL _x; _zombiesNum = count (_bPos nearEntities ["zZombie_Base",(((sizeOf _type) * 2) + 10)]); if (_zombiesNum == 0) then { _x setVariable ["zombieSpawn",_serverTime,!_islocal]; if (!(_x in dayz_buildingBubbleMonitor)) then { //add active zed to var dayz_buildingBubbleMonitor set [count dayz_buildingBubbleMonitor, _x]; }; //start spawn [_x] call building_spawnZombies; }; //diag_log (format["%1 building. %2", __FILE__, _x]); }; } else { _bPos = getPosATL _x; _zombiesNum = count (_bPos nearEntities ["zZombie_Base",(((sizeOf _type) * 2) + 30)]); //Should be a wreck if (_zombiesNum == 0) then { [_x,_isWreck] call building_spawnZombies; }; }; }; }; }; }; } forEach _nearby; At first I thought it was a respawn timer issue or something like that but if you don't move the loot will stay, you have to back away from it or someone else has to get within range and its not like you have to run away for this to happen, you can just back up a few steps and watch the loot change right infront of you. I have been playing around with it just trying to see if i can figure it out but if anyone knows what i should do or can at least point me in the right direction it would be a huge help.
       
      Thanks
    • By calinova22
      I was wondering if it is possible to make it so that a players humanity would not change for a certain amount of time? I have a PVP arena with a teleport in and I was wanting to make it so people could TP in and fight without worrying about gaining or losing humanity.
    • By totis
      Can somebody filters guru help me a bit here?
      im using aeg to except code.
      using default epoch filters i eliminated all except execvm exceptions.
      Im stuck in these (2 for example):
      1.. kick:       #27 "script = {((ctrlParent (_this select 0)) closeDisplay 7782); execvm 'custom\menu\basics2_init.sqf';};
      1.. exception=       !="script = {((ctrlParent (_this select 0)) closeDisplay 7782); execvm 'custom\\menu\\basics2_init.sqf';}; \npreviousscript = {((ctrlP"
      2.. kick:       #27 "65 execVM 'scripts\deployanything\addons\bike\deploy.sqf';"
      2.. exception=      !="65 execVM 'scripts\\deployanything\\addons\\bike\\deploy.sqf';"
      These exception dont work, keep generating same kicks over and over.
      Any ideas how to except?
       
       
       
  • Advertisement
  • Supporters
  • Discord

×
×
  • Create New...