A cronjob is a script that will be executed by cron, a time-based job scheduler in Unix-like operating systems. This features allows you to execute system calls in regular intervals for example checking your emails every 5 minutes.
The configuration of the jobs is located in /etc/crontab (on Debian based distributions).
Before adding a entry you need to know how you can define the execution interval:
# * * * * * command to execute # ┬ ┬ ┬ ┬ ┬ # │ │ │ │ │ # │ │ │ │ │ # └─│─│─│─│────────── min (0 - 59) # │ │ │ │ # └─│─│─│────────── hour (0 - 23) # │ │ │ # └─│─│────────── day of month (1 - 31) # │ │ # └─│────────── month (1 - 12) # │ # └────────── day of week (0 - 6) (0 to 6 are Sunday to Saturday, for example 0 equals Sunday and 4 Thursday)
For example if you want to run a job every half hour you have to set the params 30 * * * *
or 0 0 1 1 * runs once a year at midnight in the morning of January 1
When developing a cronjob (a real one, not a pseudo-cronjob) it is often necessary to use functionality that is provided by plugins. In order to use this you have to include the plugins yourself. This can be achieved by adding theses lines to your code:
// include plugins & call hook after plugins are loaded $cfg = cRegistry::getConfig(); require_once $backendPath . $cfg['path']['includes'] . 'functions.includePluginConf.php'; cApiCecHook::execute('Contenido.Frontend.AfterLoadPlugins');