Wednesday, August 27, 2008

On Schedules...

The Pentaho BI Platform, on which ER/Studio Enterprise Portal is based, makes use of a Quartz database to schedule its jobs. Quartz is a full-featured, open source job scheduling system can can be integrated with virtually any Java application.

Unfortunately, the schedule administration interface provided with Pentaho is somewhat cryptic (and hence difficult to use), in part because it uses cron expressions to specify job schedules. There are several tutorials on cron triggers available on the Internet, so I won't provide a full tutorial here. However, I thought it would be helpful to describe what the format of a cron expression looks like and show a few examples that might be useful to, for example, set up a schedule for the synchronization of the reporting database with the ER/Studio repository database.

A cron expression is a string of six or seven fields separated by white space. Specific values, as well as certain special characters, are allowed for each field, as follows:

  • Seconds : values are 0-59, special characters include , - * /
  • Minutes : values are 0-59, special characters include , - * /
  • Hours : values are 0-23, special characters include , - * /
  • Day of Month : values are 1-31, special characters include , - * / L W
  • Month : values are 1-12 or JAN-DEC, special characters include , - * /
  • Day of Week : values are 1-7 or SUN-SAT, special characters include , - * / L #
  • Year (optional) : values are 1970-2099, special characters include , - * /

I won't go into detail on all of the special characters, but * means "all values" and ? means "no specific value" (useful when you want to specify either day of month or day of week but not the other). Here are some examples:

  • 0 0 0 * * ? = midnight every day (the default schedule in the portal)
  • 0 30 1 L * ? = 1:30 AM on the last day of every month
  • 0 0 2 ? * 0#3 = 2:00 AM on the third Sunday of every month
  • 0 0 * * * ? = every hour

It's important to note that schedules between midnight and 1:00 AM can result in either a skip or a repeat depending on changes due to daylight savings time.

No comments: