Quick Lesson in Cron

The idea of cron comes from the UNIX world. In UNIX, cron is a daemon that runs in the background and is responsible for all timed events. Although Quartz shares nothing with UNIX cron other than the name and similar expression syntax, it's worth spending a couple of paragraphs to understand the history behind cron. Our goal here is not to confuse UNIX cron expressions and Quartz cron expressions, but you should understand the history behind the Quartz expressions and explore why they look like they do. There is obviously a great deal of intentional similarity.

Many Different Versions of UNIX Cron

You'll find different versions of cron, each with slightly different features. We're interested only in comparing against the Quartz CronTrigger, so we generalize the various UNIX versions of cron for our discussion.

The UNIX cron daemon wakes up every minute and examines the configuration files, which are called crontabs. (Crontab comes from the phrase CRON TABle, which is a list of jobs and other instructions for the cron daemon.) The daemon inspects the commands that are stored within the crontabs and determines whether any tasks need to be executed.

UNIX Cron Format

You can think of the UNIX crontab as a combination of triggers and jobs because they list both the execution schedule and the command (job) to be executed.

The Cron Expression Format

The crontab format contains six fieldsfive for the schedule and the sixth for the command to execute. (Quartz cron expression has seven fields.) These are the five schedule fields:

  • Minute (0059)
  • Hour (0023)
  • Day (131)
  • Month (112)
  • Weekday (06 or sunsat)

The UNIX cron format allows for a few special characters in the cron expression, such as the asterisk character (*), which matches all values. Here's an example of a UNIX crontab:

0 8 * * * echo "WAKE UP" 2>$1 /dev/console

This crontab entry prints the string "WAKE UP" to the UNIX device /dev/console every morning at 8 AM. Figure 5.1 shows it in action.

Figure 5.1. The UNIX Cron executing the 0 8 * * * echo "WAKE UP" 2>$1 /dev/console expression

Scheduling in the Enterprise

Getting Started with Quartz

Hello, Quartz

Scheduling Jobs

Cron Triggers and More

JobStores and Persistence

Implementing Quartz Listeners

Using Quartz Plug-Ins

Using Quartz Remotely

Using Quartz with J2EE

Clustering Quartz

Quartz Cookbook

Quartz and Web Applications

Using Quartz with Workflow

Appendix A. Quartz Configuration Reference

show all menu

Quartz Job Scheduling Framework(c) Building Open Source Enterprise Applications
Quartz Job Scheduling Framework: Building Open Source Enterprise Applications
ISBN: 0131886703
EAN: 2147483647
Year: N/A
Pages: 148
Similar book on Amazon

Flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net