1. 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?

Discussion in 'XenForo Questions and Support' started by Bill.D, Oct 14, 2014.

  1. Bill.D

    Bill.D Active Member

    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
     
  2. Mike

    Mike XenForo Developer Staff Member

    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.)
     
    Walter likes this.
  3. Bill.D

    Bill.D Active Member

    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
     
  4. Mike

    Mike XenForo Developer Staff Member

    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.
     
    eva2000 likes this.
  5. Bill.D

    Bill.D Active Member

    Awesome. My goal is to hopefully remove any overlap from the separate systems that may be occurring.

    Thanks,
    -Bill
     
  6. Bill.D

    Bill.D Active Member

    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: Oct 23, 2014
  7. Mike

    Mike XenForo Developer Staff Member

    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).
     
  8. Bill.D

    Bill.D Active Member

    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
     
  9. RoldanLT

    RoldanLT Well-Known Member

    Use Template Modification?
     
  10. Bill.D

    Bill.D Active Member

    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
     
  11. RoldanLT

    RoldanLT Well-Known Member

    This one; https://xenforo.com/community/threads/template-modifications-and-comparison.48412/
    You have to enable debug mode first.
     
  12. Bill.D

    Bill.D Active Member

    0.o I think that might be the perfect answer! Thank you!
     
  13. Bill.D

    Bill.D Active Member

    ok, here is what I did. Let me know any of the options should be different:
    Screen Shot 2014-10-28 at 10.01.57 AM.png
     

Share This Page