[Home] [Index] [Previous] [Next]

Oddjob Schedules

Flexitime.

Introduction

Oddjob Schedules provide a very flexible way of defining the schedule for running a job. Oddjob Schedules work with intervals of time. Here's an interval:

An Interval

In Oddjob this would be defined with the following XML:

<schedules:date on="2010-03-16" xmlns:schedules="http://rgordon.co.uk/oddjob/schedules"/>

Or defined in Oddjob Designer it would look like this:

Date Schedule Definition

This interval spans the whole of that Tuesday, that was the 16th of March 2010, from midnight until 1 millisecond before midnight that night.

Recurring Schedules

More commonly an interval is not specified between fixed points in time. This schedule returns the interval that is the next day of the week that is a Tuesday.

<schedules:weekly on="Tuesday" xmlns:schedules="http://rgordon.co.uk/oddjob/schedules"/>

The Tuesday selected depends on the time now.

Repeating Intervals

On Tuesday the interval is for all of that Tuesday.

Repeating Intervals

And from 00:00 Wednesday the interval is for the following Tuesday.

Repeating Intervals

Constraining Schedules

The weekly schedule allows an interval to be defined from the start of one day of the week to the end of another day of the week. This has exactly the same effect as the above:

<schedules:weekly from="Tuesday" to="Tuesday" xmlns:schedules="http://rgordon.co.uk/oddjob/schedules"/>

Note that this is an interval of 1 day, not 7 days. If the 'on' attribute is given, from and to are ignored.

Many schedules can be constrained with 'from' and a 'to' properties. They are:

With all Constrained Schedules, if the 'from' is after the 'to', then the specified interval is in the next unit of time. For instance:

<schedules:yearly fromMonth="October" toMonth="April" xmlns:schedules="http://rgordon.co.uk/oddjob/schedules"/>

Specifies an interval from this 1st of October to the end of April next year (Or from last October if now is before April this year).

Refining Schedules

Many schedules allow a refinement schedule to be specified. This is another schedule that 'refines' the interval of its parent.

Refined Schedule
<schedules:weekly on="Tuesday" xmlns:schedules="http://rgordon.co.uk/oddjob/schedules">
    <refinement>
        <schedules:time from="10:00" to="13:00"/>
    </refinement>
</schedules:weekly>

This would schedule a job at 10am every Tuesday. In this instance the time schedule has refined the weekly schedule. The day of week schedule has also 'limited' the time schedule. It no longer returns an interval that is every day from 10am to 1pm. The time now only applies to Tuesdays. This limiting effect applies to the beginning of the interval, not the end.

Refine Schedule
<schedules:weekly on="Tuesday" xmlns:schedules="http://rgordon.co.uk/oddjob/schedules">
    <refinement>
        <schedules:time from="22:00" to="01:00"/>
    </refinement>
</schedules:weekly>

Thus the interval is still applicable even if the time is 00:59am Wednesday morning. At 1:00am precisely the interval moves on to the following week.

Fixed Intervals

The interval schedule provides regular fixed length intervals.

<schedules:interval interval="00:00:05" xmlns:schedules="http://rgordon.co.uk/oddjob/schedules"/>

The schedule provides back to back intervals that are five seconds long. It would be used to schedule something every five seconds.

<schedules:weekly on="Tuesday" xmlns:schedules="http://rgordon.co.uk/oddjob/schedules">
    <refinement>
        <schedules:time from="22:00" to="01:05">
            <refinement>
                <schedules:interval interval="00:30"/>
            </refinement>
        </schedules:time>
    </refinement>
</schedules:weekly>

This will provide thirty minute intervals from 10pm Tuesday night until 1:30am Wednesday morning. Intervals are calculated form the parents limits and so would be on the hour and half our. The final interval runs until 1:30am even though it's parent finishes at 01:05. This is because, like the Constrained Schedules the limiting affect of the parent only applies to the beginning of the interval.

Schedule Lists

The list schedule provides for even greater flexibility.

<schedules:list xmlns:schedules="http://rgordon.co.uk/oddjob/schedules">
    <schedules>
        <schedules:weekly on="Monday">
            <refinement>
                <schedules:time at="08:00"/>
            </refinement>
        </schedules:weekly>
        <schedules:weekly from="Tuesday" to="Sunday">
            <refinement>
                <schedules:list>
                    <schedules>
                        <schedules:daily at="09:00"/>
                        <schedules:daily at="15:00"/>
                    </schedules>
                </schedules:list>
            </refinement>
        </schedules:weekly>
    </schedules>
</schedules:list>

This would schedule a job at 8am every Monday, then at 9am and 3pm every other day.

When a schedule is evaluated each schedule in the list is evaluated and the first due schedule is used as the next due date.

The list of sub schedules can be quite unrelated.

<schedules:list xmlns:schedules="http://rgordon.co.uk/oddjob/schedules">
    <schedules>
        <schedules:weekly on="Wednesday">
            <refinement>
                <schedules:time at="12:00"/>
            </refinement>
        </schedules:weekly>
        <schedules:monthly onDay="5"/>
        <schedules:daily at="14:00"/>
    </schedules>
</schedules:list>

Holiday Schedules

We already saw in scheduling how broken schedules can be used to define holidays but here's a little more on how they work.

Broken Schedule

The intervals defined by the breaks mask those defined by the regular schedule. As with other schedules, the break only masks a interval where its start is in the break interval.

Schedules can moved around breaks. For more information see the examples with the day-after and day-before schedules.


[Home] [Index] [Previous] [Next]