Creating a Schedule

この手順で新しいスケジュールを作成できます:

SYSADMIN.CreateSchedule(<IN biginteger jobId>, <IN string type>, <IN biginteger intervl>, <IN biginteger startDelay>, <IN string cronExpression>, <IN boolean enabled>, <IN biginteger chainedToScheduleId>, <IN string chainCondition>, <IN string chainString>, <IN string owner>, <IN string scheduleName>, <IN string queueHandler>, <IN string jobUuid>, <IN string uuid>, <IN string timezone>)

以下のパラメータを取ります:

To view the full table, click the expand button in its top right corner

Parameter

Description

jobId

Id of the job the schedule belongs to (id of a ScheduleJob).

type

Can take one of four possible values; depending on the value, some other parameters are required or disregarded:

  • once: only startDelay and the enabled parameters are used
  • intervl: interval and startDelay parameters are used, cronExpressionchainedToScheduleId, and chainCondition are disregarded
  • cron: cronExpression and startDelay parameters are used, intervl, chainedToScheduleId, and chainCondition are disregarded
  • chained:  only chainedToScheduleId and chainCondition parameters are used

intervl

How often to repeat the job in minutes. If this parameter is used, the cronExpression parameter is disregarded

startDelay

Initial delay before running the job (only before the 1st iteration, all subsequent iterations are fired in accordance with interval/cron schedule settings)

cronExpression

Provides the Quartz Cron Expression to specify the schedule. If this parameter is used, the intervl parameter is disregarded, but the startDelay parameter is used. This means that depending on the actual configuration, the event may or may not fire at this specific time; however, the trigger will not fire before this time. If we start a schedule at 17:59 with cron string having '18:00' and set the start delay to 2 minutes, then the event will fire at 18:00 of the following day

enabled

Enables the execution of the schedule according to interval or cronExpression parameters

chainedToScheduleId

ID of the parent schedule, i.e. this schedule will be executed after the parent schedule if chainCondition is fulfilled

chainCondition

Can take the following possible values:

  • UNCONDITIONAL: this schedule is always executed after the parent schedule)
  • SUCCESS: this schedule is only executed if parent schedule succeeds
  • FAILURE: this Schedule is only executed if parent Schedule fails

If NULL is provided, UNCONDITIONAL is set as default

chainString

Expression string when complex dependencies are used; see the section further down for a detailed explanation. If the created schedule depends only on one other schedule, either chainedToScheduleId is not NULL and chainString is NULL, or chainedToScheduleId is NULL, chainCondition is NULL, and chainString is not NULL

owner

The name of a schedule owner. Default: the user who runs the SYSADMIN.createSchedule procedure. Owner can be set to the value that is not equal to the current user only by members of admin-role

scheduleName

Meant to support synchronization processes between the CData Virtuality Server instances. It is not meant to be freely editable or selectable and should not be modified without very good reason. When scheduleName is absent from the procedure call, it is created by the system automatically. The system will also create scheduleName on the CData Virtuality Server start when it encounters any schedule without scheduleName set

queueHandler

Name of queue handler. If not set, system will be used for system jobs, and default will be used for other jobs

jobUuid

UUID of the job the schedule belongs to (UUID of a ScheduleJob)

uuid

Custom UUID of the schedule to be created

timezone

Define the timezone for the schedule (timezoneId column from SYSADMIN.Timezones table). Time zone will only affect schedules of type CRON

ownerjobUuid, uuid parameters in SYSADMIN.createSchedule are available since v4.1

timezone parameter in SYSADMIN.createSchedule is available since v4.8 

Examples

1.  一度だけ実行されるシンプルなスケジュールを作成します:

CALL SYSADMIN.CreateSchedule(135, 'once', 0, 0, NULL, true, null, null, null)

2. 与えられたintervalstartDelayで簡単なスケジュールを作成し、すぐに実行します:

CALL SYSADMIN.CreateSchedule(1, 'interval', 1, 0, null, true, null, null, null)

3. cron式でScheduleを作成します。例えば、1回目は毎週月曜日と火曜日の午前3時から、2回目は毎日午前5時から開始します:

CALL SYSADMIN.CreateSchedule(321, 'cron', 1, 1, '0 0 3 ? * MON,TUE *', true, null, null, null)
CALL SYSADMIN.CreateSchedule(159, 'cron', 1, 1, '0 0 5 1/1 * ? *', true, null, null, null)

4. アメリカ/シカゴのタイムゾーンで毎日午前5:00に開始するタイムゾーンを調整したcron式でスケジュールを作成します:

CALL SYSADMIN.CreateSchedule(159, 'cron', 1, 1, '0 0 5 1/1 * ? *', true, null, null, null, null, null, null, null, null, "America/Chicago")

5. ID15のスケジュールが正常に終了した後に実行される、ID3のジョブの連鎖スケジュールを作成します:

CALL SYSADMIN.CreateSchedule(3, 'chained', null, 0, null, true, 15, 'SUCCESS', null)

Cron Expressions

Cron 式はQuartz Schedulerの構文を使用します。特定のスケジュールに対するExpressionsを簡単に構築するには、CronMaker siteをご確認ください。

以下のセクションは、CronTrigger tutorialおよびorg.quartz.CronExpression documentationに由来し、Apache License 2.0の著作権で保護されています。

Syntax

これらの式はCronTriggerのインスタンスを構成するために使用されます。これらは、実際にはスケジュールの個々の詳細を記述する7つのサブ式からなる文字列です。これらのサブ式は空白で区切られ、以下の要素を表します:

  1. Seconds
  2. Minutes
  3. Hours
  4. Day of month
  5. Month
  6. Day of week
  7. Year (optional field)

完全なcron式の例として、0 0 12 ? * WED という文字列があります。これは「毎週水曜日12:00:00」という意味です。

個々の部分式には範囲やリストを含めることができます。例えば、先ほどの例の曜日フィールド(WED)は、MON-FRIMON,WED,FRIMON-WED,SAT

すべてのフィールドには指定可能な有効値の設定があります。例えば、秒と分は0から59まで、時間は0から23までです。DAYには1から31までの任意の値を指定できますが、指定した月の日数には注意が必要です!月は 1 から 12 までの値で指定するか、文字列JAN , FEB , MAR , APR , MAY , JUN , JUL , AUG , SEP , OCT , NOV , DECで指定できます。曜日は、1 から 7 までの値(1 = 日曜)、または文字列SUN , MON , TUE , WED , THU , FRI , およびSATで指定することができます。

Field name

Allowed values

Allowed special characters

Seconds

0-59

, - * /

Minutes

0-59

, - * /

Hours

0-23

, - * /

Day of month

1-31

, - * ? / L W

Month

1-12 or JAN-DEC

, - * /

Day of Week

1-7 or SUN-SAT

, - * ? / L #

Year (optional)

empty, 1970-2199

, - * /

To view the full table, click the expand button in its top right corner

Character

Possible field(s)

Meaning

-

All

Ranges: 1-4 or SUN-WED

,

All

Additional values: MON,WED,FRI

*

All

Every possible value of this field. Thus, the * in the Month field of the previous example simply means "every month"

/

All

Increments to values. For example, 0/15 in the Minutes field means 'every 15th minute of the hour, starting at minute zero'. If you use 3/20 in the Minutes field, it would mean 'every 20th minute of the hour, starting at minute three' - or in other words, it is the same as specifying 3,23,43 in the Minutes field.

Please note that /35 does not mean "every 35 minutes" - it means "every 35th minute of the hour, starting at minute zero" - or, in other words, the same as specifying 0,35.

?

Day of month

Day of week

No specific value. This is useful when you need to specify something in one of the two fields, but not the other. See the examples below (and CronTrigger JavaDoc) for clarification

L

Day of month

Day of week

Short-hand for "last", but has a different meaning in each of the two fields:

  • Day of month: "the last day of the month" - day 31 for January, day 28 for February on non-leap years
  • Day of week: if used by itself, simply means 7 or SAT. But if used in the day of week field after another value, it means "the last xxx day of the month" - for example, 6L or FRIL both mean "the last Friday of the month". You can also specify an offset from the last day of the month, such as L-3, which would mean the third-to-last day of the calendar month.

Please note that when using the L option, it is important not to specify lists, or ranges of values, as you may get confusing/unexpected results

W

Day of month

Day of week

Weekday (Monday to Friday) closest to the given day. For example, 15W means "the nearest weekday to the 15th of the month"

#

Day of week

The Nth XXX weekday of the month. For example, 6#3 or FRI#3 means "the third Friday of the month"

以下に、式とその意味の例をいくつか示します。org.quartz.CronExpression のJavaDoc には、さらに多くの例が記載されています。

Examples

1. 5分ごとに起動するトリガーを作成します:

0 0/5 * * * ?

2. 5分ごとに、分の10秒後(午前10時00分10秒、午前10時05分10秒など)に起動するトリガーを作成します:

10 0/5 * * * ?

3. 毎週水曜日と金曜日の10:30、11:30、12:30、13:30に起動するトリガーを作成します:

0 30 10-13 ? * WED,FRI

4. 毎月5日と20日の午前8時から午前10時の間、30分ごとに起動するトリガーを作成します。TRIGGERは10:00には作動せず、8:00、8:30、9:00、9:30に作動します:

0 0/30 8-9 5,20 * ?

例えば、"9:00から10:00の間は5分ごと、13:00から22:00の間は20分ごと "といった具合です。このシナリオでの解決策は、単純に2つのトリガーを作成し、同じジョブを実行するように両方を登録することです。

Schedules Table

To view the full table, click the expand button in its top right corner

Value

Description

id

Unique id of the schedule itself

jobID

Id of the job the schedule belongs to (id of a ScheduleJob)

type

Can take one of four possible values; depending on the value, some other parameters are required or disregarded:

  • once: only startDelay and the enabled parameters are used
  • interval: intervl and startDelay parameters are used, cronExpression has NULL value
  • cron: cronExpression and startDelay parameters are used, intervl has no meaningful value
  • chained: chainedTo and chainCondition parameters are used

intervl

How often to repeat the job in minutes

startDelay

Initial delay before running the job (only before the 1st iteration, all subsequent fire in accordance with interval/cron schedule settings)

cronExpression

Quartz Cron Expression which specifies the schedule

enabled

Whether the schedule is active or not

chainString

Logical expression for the dependencies on other jobs

nextFireTime

Date and time of the subsequent planned job fire (if the schedule is active, i.e. the enabled field contains TRUE)

owner

Name of the schedule owner

uuid

Unique UUID of the schedule itself

cronTimezone

Time zone for the schedule (timezoneId from SYSADMIN.Timezones)

cronTimezone column in SYSADMIN.Schedules is available since v4.8