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

Trigger deferred.php Via Shell Crontab

Allow an automated shell process to run deferred.php script

  1. digitalpoint

    digitalpoint Well-Known Member

    digitalpoint submitted a new resource:

    Trigger deferred.php Via Shell Crontab - Allow an automated shell process to run deferred.php script

    Read more about this resource...
     
    euantor and Mouth like this.
  2. Marcus

    Marcus Well-Known Member

    Nice!
     
  3. Alfa1

    Alfa1 Well-Known Member

    Thanks Shawn!
     
  4. motowebmaster

    motowebmaster Active Member

  5. MattW

    MattW Well-Known Member

    Thanks Shawn :)
     
  6. Adam Howard

    Adam Howard Well-Known Member

    I'm confident that this is unrelated and @digitalpoint has nothing to worry about. The only error I have gotten in 24 hours with this being the only change was

    http://xenforo.com/community/threads/sitemap-for-xenforo-1-2-compatible.26785/page-36#post-663390

    But I did figure out a solution

    http://xenforo.com/community/threads/sitemap-for-xenforo-1-2-compatible.26785/page-36#post-663392

    And it maybe only my setup. So no worries, but I'll make a note if it here just in case anyone else runs into it (or feels the need to take pre-emptive measures)
     
  7. digitalpoint

    digitalpoint Well-Known Member

    If you have something custom that is triggered by a cron task that is reliant on the permissions of the user the task is running on the server as, it could be an issue. You can change what system user it runs as in the cron file if you needed... Although not sure what couldn't be run as root.
     
  8. MattW

    MattW Well-Known Member

    Had the same on my site last night. Even though I'm running as the root account.
     
    Adam Howard likes this.
  9. Adam Howard

    Adam Howard Well-Known Member

    It's an easy fix and as far as I can tell that is the only add-on (site map) that I had to adjust for
     
  10. HWS

    HWS Well-Known Member

    You should run the cron as the web server user.

    Also this setup makes no sense at all with small boards.
     
    SneakyDave likes this.
  11. MattW

    MattW Well-Known Member

    True, but some people just like to do this "because they can" ;)
     
  12. RoldanLT

    RoldanLT Well-Known Member

    So it's fine also if I will just append the command on my default cron?
    ie. "crontab -e"
     
  13. Marcus

    Marcus Well-Known Member

    Yes.
     
    RoldanLT likes this.
  14. Will this script processes anything in the xf_deferred table, updating cache's its horrible that these need to be run on the web and can't be run in the CLI in a screen or something else.
     
  15. HWS

    HWS Well-Known Member

    Just a small thought: I would run the cron as the web server user. You never know what deferred is going to do, and running it as the same user like when triggered from XenForo itself is always a good idea…
     
    thedude likes this.
  16. RoldanLT

    RoldanLT Well-Known Member

    Just applied again this, Thanks :)
     
  17. Sim

    Sim Well-Known Member

    There are a couple of things to be aware of ... first, if you want to completely disable the RunDeferred javascript trigger - there are two more of them contained in the Admin side - you'll need to modify the Admin PAGE_CONTAINER and PAGE_CONTAINER_SIMPLE templates to remove RunDeferred from there as well.

    Also, if you have XFMG installed, it has its own public facing page container - xengallery_page_container which also contains RunDeferred.

    Finally, if you call the deferred.php script directly, there are quite a few things that could potentially break - especially anything wanting to generate full urls using XenForo_Link::buildPublicLink ... since this will try and extract server name information which simply isn't available when running PHP from CLI - that information comes directly from the web server, which is bypassed when using CLI.

    (I discovered this when one of my addons tried to send emails with links to threads on the forum but sent them without the domain name - URLs were like this: http:///threads/mythread.1/ )

    The simplest way to overcome this is to instead use cURL to trigger your deferred.php script, rather than triggering it directly from CLI.

    Code:
    * * * * *       curl --silent 'http://example.com/deferred.php' > /dev/null 2>&1
    Because cURL will actually call your web server and ask it to communicate with PHP (just like any web browser will), scripts called this way have full access to all server variables, including the domain name, so everything will work exactly as expected.
     
    RoldanLT, Mayhem30, eva2000 and 4 others like this.
  18. maxicep

    maxicep Active Member

    I removed the {xen:if $hasAutoDeferred, RunDeferred} line but webpage still calling the deferred.php when i look the chrome developer console.

    Can you help me @Sim or @digitalpoint ?
     
    Last edited: Jun 28, 2015
  19. Sim

    Sim Well-Known Member

    Which templates did you remove that from? Which pages are you viewing that you still see it on?
     
  20. maxicep

    maxicep Active Member

    I removed it from page_container and i m still see that on thread view pages @Sim
     

Share This Page