Resource Library
Resin

Change Log
Documentation

Orientation
Features
Installation
Configuration
Web Applications
JSP
Servlets and Filters
Databases
Admin (JMX)
Security
XML and XSLT
XTP
Resources (JNDI)
Performance
Protocols
Third-party
Troubleshooting

Library
Tutorials
Scrapbook
Resources (JNDI)
Resources (JNDI)
Tutorials

CronResource

CronResource executes application Work tasks at configured intervals.

Often, applications need to run a task at specific times. The CronResource provides a standard way of doing that. Applications need only create a standard javax.resource.Work task and configure the CronResource. Resin can configure the work task with bean-style configuration.

Task running every 15 minutes
<web-app xmlns="http://caucho.com/ns/resin">
  <resource type="com.caucho.resources.CronResource">
    <init>
      <cron>*/15</cron>
      <work bean-class="example.Work">
        <foo>Custom Config</foo>
      </work>
    </init>
  </resource>
</web-app>

cronSpecifies the times the task should be runrequired
workSpecifies application's work beanrequired

The cron specification follows the Unix crontab format. The cron is composed of 5 fields: minutes, hours, day of month, month, and day of week.

Each field specifies a range of times to be executed. The patterns allowed are:

example ranges
rangeexplanation (using minutes as example)
*run every minute
*/5run every 5 minutes
0,5,50run at :00, :05, :50 every hour
0-4run at :00, :01, :02, :03, :04
0-30/2run every 2 minutes for the first half hour

The minutes field is always required, and the hours, days, and months fields are optional.

example times
rangeexplanation
0 */3run every 3 hours
15 2 *run every day at 0215 local time
0 0 */3run every third day at midnight
15 0 * * 6run every Saturday at 0015


Resources (JNDI)
Resources (JNDI)
Tutorials
Copyright © 1998-2003 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark, and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc.