How cron jobs are run

It must be stressed that such cron jobs will not run at all if no-one ever visits the pages that have the #SPIP_CRON tag embedded - they are not cron jobs scheduled on the server, as might be assumed, they are simply procedures that are run intermittently and triggered by the activity of visits to the website pages themselves.

The tasks to be executed are called each time a site visitor views the page. A visitor’s viewing of a page only executes a single cron task for each page called, if there is actually one to be processed.

However, for tasks to be called, the #SPIP_CRON tag must be present in the page template. This tag returns an empty image, but will run the task processing script. A text browser also runs the periodic tasks if the tag is not present.

To call the cron, you only need to execute the cron() function. This function takes an argument specifying the number of seconds which must elapse before another task can be launched, 60 seconds by default. Calls using #SPIP_CRON are applied every 2 seconds with the following code:


Author Mark Baber Published : Updated : 12/03/23

Translations : English, français