The recurring background tasks, such as the match simulation or updating statistics, are triggered by jobs. By default, you start these jobs in the AdminCenter at Jobs. This page will send infinite requests which usually stop only once the server is restarted.
However, besides the fact that you should monitor the jobs state at least daily, many servers are configured in a way that they do not allow infinite requests. In this case, the jobs will run only a couple of minutes.
The only reliable way of running the jobs is setting up Cron jobs. These are processing which are started by the operating system at configured time intervals. Even when the server is restarted, it will automatically start the jobs as well.
You need to create a separate script file for every job. We reommend to set up such a script at least for the match simulation
You need to know the ID of the job first. You will find all IDs in the file /admin/config/jobs.xml.
For example, the ID of the simulation job is
As next step, we create a new PHP file, e.g. "executeSimJob.php".
Copy the following content into your new file:
<?php // Path to the websoccer installation define("BASE_FOLDER", __DIR__ ."/path/to/websoccer"); // ID of the Job $jobId = "sim"; // Code below can remain without changes define("JOBS_CONFIG_FILE", BASE_FOLDER . "/admin/config/jobs.xml"); include(BASE_FOLDER . "/admin/config/global.inc.php"); $xml = simplexml_load_file(JOBS_CONFIG_FILE); $jobConfig = $xml->xpath("//job[@id = '". $jobId . "']"); $jobClass = (string) $jobConfig->attributes()->class; $i18n = I18n::getInstance($website->getConfig("supported_languages")); $job = new $jobClass($website, $db, $i18n, $jobId); $job->execute(); ?>
Note about that path that you need to specify in the very beginning of the script: Assuming you have the folloing folder structure on your server:
Then the first line would look like this:
define("BASE_FOLDER", __DIR__ ."/htdocs/websoccer");top
You talk about "Cron jobs" usually only in the Unix/Linux world. Most of the web servers use such an operating system. If you use a Windows machine, you need to create a "Scheduled Task". Please get in touch with us if you have any doubts. In the following, we explain how you would set up a Cron job under Unix/Linux.
Usually your web hoster will provide a web form for configuring Cron jobs. Depending on how user friendly they are designed, you can specify a point of time of execution in a special format. You need to specify in a particular order, at wich minute, hour, day, month and day of week the job shall be executed. You can use a wildcard sign * which means "irrelevant" and the characters combination */ indicates an interval. For executing our simulation job every minute, the configuration would look as follows:
In addition, you need to specify a command for this job. For the example above, this command would look like:
Whereas the path /usr/bin/php depends on your server set up. The ~ represents the folder to which you have access with your common FTP account. Again, all pathes depend on how the server is configured.