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

Triggering the cron process

Discussion in 'XenForo Development Discussions' started by SneakyDave, Nov 11, 2014.

  1. SneakyDave

    SneakyDave Well-Known Member

    I realized that the cron functions of a XenForo installation won't trigger on time if there are no visitors to a web site, which makes sense I guess because it would require the index.php script to executed in order to see if there are any cron entries to run.

    To force the cron events to fire, can I just set a "real" cron to visit the web site during down time to make sure those cron activities get fired when I want them to?
     
  2. Chris D

    Chris D XenForo Developer Staff Member

  3. Aayush

    Aayush Well-Known Member

    Crontabs in shell are the only way to go as far as I know. Or maybe you could have another web service ping your website at regular intervals but that again would be using cron tabs to implement something like that.
     
  4. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    Pinging index.php wont help, because the actual defer is executed in deferred.php which is called via javascript, you will have to ping http://yoursite.com/deferred.php
     
    SneakyDave likes this.
  5. SneakyDave

    SneakyDave Well-Known Member

    But hitting deferred.php only triggers deferred tasks right, or will it make sure all scheduled tasks run?
     
  6. Chris D

    Chris D XenForo Developer Staff Member

    The solution I posted above works.

    Crons are launched via a deferred task. Hit deferred.php as described in my link above, and your crons (and any associated tasks) will run, unattended.
     
    SneakyDave likes this.
  7. SneakyDave

    SneakyDave Well-Known Member

    I'll have to take a look at this a little more closely. I have an add-on that I thought was running via this solution, but it's actually erroring out for some reason. Thanks Chris
     
  8. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

  9. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    btw, the defer also includes running the cron entries ;)
     
  10. SneakyDave

    SneakyDave Well-Known Member

    Yeah, I can get it to execute via defer.php, but there is some error happening just that I'm trying to track down. Thanks.

    It isn't necessary to PAGE_CONTAINER to remove the call to:
    Code:
    {xen:if $hasAutoDeferred, RunDeferred}
    Is it? You'd only have to remove that if you were getting too many calls to defer.php, right?
     
  11. SneakyDave

    SneakyDave Well-Known Member

    Never mind, the error I'm getting is a permission problem, the cron isn't running as the same user as the web server userid, so I just need to make sure the same one is running there.
     
  12. Mr. Goodie2Shoes

    Mr. Goodie2Shoes Well-Known Member

    Correct. :)
     
    SneakyDave likes this.
  13. SneakyDave

    SneakyDave Well-Known Member

    Well, no, that's not it, the cron process it just hitting the defer.php script, it doesn't have any connection to the add-on running, which should be the web server user. I'll have to just shut up and dig into it some more.
     
  14. SneakyDave

    SneakyDave Well-Known Member

    As an update, running deferred.php from cron works great, my errors were just permission based due to a recent upgrade, nothing to do with deferred.php or running it from shell.

    I/O error - Incompetent Operator
     

Share This Page