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

XF 1.1 Cron Entry for CometChat

Discussion in 'XenForo Questions and Support' started by Jeff Fuqua, Jul 18, 2012.

  1. Jeff Fuqua

    Jeff Fuqua Well-Known Member

    I'm attempting to create a cron entry every three hours to run this file:

    http://www.yoursite.com/cometchat/cron.php

    I see how to add one but don't understand the cron callback and where I insert the link.
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    The callback needs a class and method within XenForo's namespace. Create a directory and PHP file to define a class. For example, create:

    library/Comet/Cron.php

    Code:
    <?php
    
    class Comet_Cron
    {
    	public static function runCron()
    	{
    		include 'http://www.yoursite.com/cometchat/cron.php';
    	}
    }
    
    Then your callback would be:

    Class = Comet_Cron
    Method = runCron
     
  3. Jeff Fuqua

    Jeff Fuqua Well-Known Member

    Thanks for your reply.

    There's already a cron.php on the root for another xenforo add-on. Can I name this "cron2.php" and change the code you gave me to say "runCron2" on the fifth line?
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Yes. But you need only update this code:

    Code:
    include 'http://www.yoursite.com/cometchat/cron2.php';
    
     
  5. Jeff Fuqua

    Jeff Fuqua Well-Known Member

    I think I goofed up with my info.

    There is already a cron.php in the cometchat folder which, I assume is what is supposed to run.

    In their info on optimizing, they say:

    Run http://www.yoursite.com/cometchat/cron.php periodically (every 3 hours)
     
  6. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Did you create the library/Comet/Cron.php file in your xenforo directory?
     
  7. Jeff Fuqua

    Jeff Fuqua Well-Known Member

    Sorry for the confusion.

    The Comet folder was installed on the root. There is no Comet folder in the library right now.

    Do I need to make one?
     
  8. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Yes.
     
  9. Jeff Fuqua

    Jeff Fuqua Well-Known Member

    Okay. Got a Cron.php file as you outlined in post #2 above and placed it in a Comet folder in the library. Here's the result when I made a run:

    Server Error

    include() [function.include]: http:// wrapper is disabled in the server configuration by allow_url_include=0
    1. XenForo_Application::handlePhpError() in Comet/Cron.php at line 7
    2. Comet_Cron::runCron() in Comet/Cron.php at line 7
    3. Comet_Cron::runCron()
    4. call_user_func() in XenForo/Model/Cron.php at line 356
    5. XenForo_Model_Cron->runEntry() in XenForo/ControllerAdmin/Cron.php at line 204
    6. XenForo_ControllerAdmin_Cron->actionRun() in XenForo/FrontController.php at line 310
    7. XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 132
    8. XenForo_FrontController->run() in /home/xxxxxx/public_html/admin.php at line 13
     
  10. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Alternatively you can specify the server path to the file:

    Code:
    include '/path/to/cometchat/cron2.php';
    
     
  11. Chris D

    Chris D XenForo Developer Staff Member

    Having worked on your server, Jeff, for you the code would be


    Code:
    include '/home/yourFTPusername/public_html/library/Comet/Cron.php';
    
     
    Jeff Fuqua likes this.
  12. Jeff Fuqua

    Jeff Fuqua Well-Known Member

    That took care of it. The first time I ran it, I got an error but tried again and it went through fine.

    Thanks for all the help.
     
    Chris D likes this.
  13. jayramfootball

    jayramfootball Active Member

    I am trying to do something similar - I want to create some tables on my database and have the php file:

    /library/UpdateRatingsComments/Ratings.php

    to do the job.

    I want a cron to run the php regularly.

    I have created the following Cron.php file:

    PHP:
    <?php
     
    class Ratings_Cron
    {
        public static function 
    runCron()
        {
            include 
    'http://www.arsenaltalk.net/library/UpdateRatingsComments/Ratings.php';
        }
    }
    When creating my cron I am using

    Class : Ratings_Cron
    Method : runCron

    however I get the following error:

    "Please enter a valid callback method." when trying to create the cron job

    What am I doing wrong here?
     
  14. jayramfootball

    jayramfootball Active Member

    I think I got it - I have to call the class the same as the folder name (y)
     
    Jake Bunce and Chris D like this.
  15. grunjuger

    grunjuger New Member

    Thanks guys!
    i finally managed to deal with this cometchat cron.php :)
     
  16. grunjuger

    grunjuger New Member

    Finally not completely solved. I got this error...

    Anyone can help me? Thanks!
     
  17. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  18. grunjuger

    grunjuger New Member

    Sorry but after reading and reading, I don't understand what I should do...
    Quite noob in this kind of modifications...
     
  19. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Surround your require or include line with ob functions. This is the code example linked above:

    Code:
            ob_start();
            require('/path/to/your/html/file.html');
            $myContent = ob_get_contents();
            ob_end_clean();
    
     
  20. grunjuger

    grunjuger New Member

    Hum ok but what should I use instead of the
    ???

    Currently my file looks like this:

    PHP:
     <?php
     
    class Comet_Cron
    {
        public static function 
    runCron()
        {
            include 
    '/home2/grenon/public_html/cometchat/cron.php';
        }
    }
     

Share This Page