• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.4 Load Balanced Server - Disable Cron?

Bill.D

Active member
#1
Hey All,

I have about 7 Systems involved in a Load Balanced Site. Is it possible to Disable Cron on all servers but one. They Share a single DB & MemcacheD Server and they all have separate config.php files.

Thanks,
-Bill
 

Mike

XenForo developer
Staff member
#2
Your best bet would be to just overwrite deferred.php with:
Code:
{"moreDeferred":false}
And then remove the RunDeferred stuff from the <html> tag of PAGE_CONTAINER.

On your one server, you can have deferred2.php (or whatever you want to call it) that is called via cron. Note that this system runs more than just cron and various happenings will trigger actions so you should probably be calling this once per minute at least. (There are admin actions that can trigger it as well, but they're blocking actions so they're run in the control panel by the browser of the triggering admin.)
 

Bill.D

Active member
#3
ok, to make sure I have understood correctly.

By Overwrite you mean that deferred.php should look like this after:
Code:
<?php

{"moreDeferred":false};

?>
Or am I replacing some code?

Is the deferred2.php file to have to original content of the deferred.php file?

By running the deferred2.php via linux cron every min, will all the cron tasks listed still trigger based on there timing Entry?

Thanks,
-Bill
 

Mike

XenForo developer
Staff member
#4
Replace the entire content with just this (I think this should work):
Code:
{"moreDeferred":false}
Deferred2.php would contain the original code. By running it via the cron consistently, the XF cron tasks will run within a minute of their scheduled time.
 

Bill.D

Active member
#6
Hey Mike,

Can I comment the line out like this:
Code:
<xen:comment> {xen:if $hasAutoDeferred, RunDeferred} </xen:comment>
Also, would there be a tell tale way of identifying if its still running the cron effectively after the changes?

-Bill
 
Last edited:

Mike

XenForo developer
Staff member
#7
Commenting it out like that would work. Note that deferred.php could still be called via the admin templates unless you remove the same thing from those templates (which may get overwritten when upgrading), hence the recommendation to remove that.

If it's removed and deferred.php is changed, you should be able to confirm it's running by checking the next run times for the cron entries; they should generally be in the future (and maintain that over time).
 

Bill.D

Active member
#8
Hey Mike,

I believe I have it working correctly. Thank you!

Question:
I am working on some automation scripts and I want to make sure that if someone were to undo my changes in PAGE_CONTAINER that I would have a script that would put my changes back. I found the PAGE_CONTAINER template in the database. Could I just use a BASH script to test that entry and if its missing my change to go ahead and run a string replace query to place the run deferred commend back into a comment tag? OR is there a better way?

Thanks,
-Bill
 

RoldanLT

Well-known member
#9
Hey Mike,

I believe I have it working correctly. Thank you!

Question:
I am working on some automation scripts and I want to make sure that if someone were to undo my changes in PAGE_CONTAINER that I would have a script that would put my changes back. I found the PAGE_CONTAINER template in the database. Could I just use a BASH script to test that entry and if its missing my change to go ahead and run a string replace query to place the run deferred commend back into a comment tag? OR is there a better way?

Thanks,
-Bill
Use Template Modification?
 

Bill.D

Active member
#10
Hey Roldan,

Is that through PHP? a Hook? The Template in question is a separate templet from the default built in one that gets over written in an upgrade. I am trying to prevent someone either manual undoing my change, OR reverting the template for some other reason.

Thanks,
-Bill
 

RoldanLT

Well-known member
#11