logo

MMBase tips

Cron jobs

tip #21 / Fri 14 Oct 2011 / André / 0 comments

MMBase has a simple but effective application for cron jobs named MMBase Crontab. Cron jobs can be scheduled via a configuration file, or just by creating cronjob nodes.

The application has a config file at 'config/utils/crontab.xml'. The syntax of jobs is similar to those in cron on Unix et al.

Values are seperated by a |, in this example: timeschedule (run every morning at 1), Java class to run, a descriptive name and the last part is a piece off configuration to be used by the Java class.

<property name="lucenefullindex">
0 1 * * *|org.mmbase.module.lucene.FullIndex|Lucene Full Index|forum
</property>

The following example prints memory usage to the log file every two hours.

<property name="memorystats">
0 */2 * * *|org.mmbase.applications.crontab.MMBaseStatsJob||Memory|short
</property>

An example config file in the Crontab application itself contains more examples.

Cron nodes

Cron jobs can also be made as nodes. Which is even more flexible since you can easily edit them in one of the editors.
The same cron job from the first example but now as a node has the following field values:

  • name: Lucene full index
  • crontime: 0 1 * * *
  • classfile: org.mmbase.module.lucene.FullIndex
  • config: forum

The last field 'config' refers to the index to be done named 'forum', when left empty a full index will run on all indexes.

When you have multiple MMBase instances clustered on one server, you should relate you cronjobs node to the mmservers node of the server it should run on. Or it will run on all instances, which of course can also be a feature.

0 comments

RSS feed

Tweet this article

Most mentioned links:

MMBase documentation
MMBase API
MMBase SVN
Bugtracker
MMBase Taglib reference
The reference for all tags mm