The purpose of this page is to give the Jomres plugin developer a brief overview of how to install and create pseudocron jobs for Jomres.
Jomres supports a pseudo cron system, IE a system that works a bit like timed jobs in linux (cron). Cron jobs are called on a timed basis depending on how the cron job was installed (this cannot be changed at a later time, except by manually editing a table).
Installation of a cron job
As a plugin developer, you will want to tell Jomres that there are scripts you want to call on a timed basis. You do this in the plugin_install.php of your plugin. An example can be seen on the Creating plugins page.
jr_import('jomres_cron'); // Note, this line is new for v4.2. If you're creating for 4.2 or greater, you'll need this.
$cron = new jomres_cron($displayLog);
This functionality "registers" the cron job with the pseudocron functionality, and the intervals are as follows.
"M": // Every minute "H": // Every hour "D": // Every day "W": // Every week
The cron job file itself
A cron job file is just like any 06000 task, ie it can be called by anybody. Take a look at the Jomres core file j06000cron_invoice.class.php. If you open it up it you'll see that it's the script's task to find orphan line items (for commission charging purposes) and add them to new commission invoices. This script can, if you wish, be called directly from the command line. It doesn't act on any variables that are passed to it.
That's it. It's very simple. Create a 06000 task that "does stuff", then use ''addJob'' in ''plugin_install.php'' to tell Jomres to call it from time to time.
This document is copyright Vince Wooll/Woollyinwales IT, 2011. All rights reserved.