Cron Invalid Callback

Betclever

Well-known member
Hi everyone,

I tried to implement a php script as a cron on the xenforo admin panel. Unfortunatly it doesn't work, I tried to find the best way to make it as simple as possible.

I didn't find the way for xenforo to recognize my file. Do I have to specify the location of my php script ?

Do I have to declare a class or a function ? My script is a simple one and work perfectly when I run it manually via his url.

Thank you very much for your help.
 
When you create a Cron entry you have to enter a class name and a function name.

The class name identifies the location of the file on the file system relative to the library directory. If you want your file to be in the library/MyCron/MyCronClass.php file, then the class name should be MyCron_MyCronClass.

This would look like:
PHP:
<?php

class MyCron_MyCronClass
{

}

The code to run needs to be in a function, if you wanted to name that "myFunction" that would look like:
PHP:
<?php

class MyCron_MyCronClass
{
    public static function myFunction()
    {
        // Your code to run would go here
    }
}

As you can see above, your code will go where the commented out line starting with // is.

When setting up the cron, you would enter the Cron callback as:

Class: MyCron_MyCronClass
Method: myFunction
 
Top Bottom