This library provides a high-level scheduler component to the REBOL language for short-term (a few seconds) and long-term jobs (months) using a simple, almost natural dialect (also called a DSL).
Main features :
- Simple, yet powerfull dedicated dialect for jobs (no cryptic CRON-like job descriptions)
- Callback based API
- Transparently integrates within any View or network application
- Cross-platform alternative to CRON
- Can easily run as a standalone application
Launch a script at a precise date and time :
at 18:30 do %batch.r at 10-Sep-2009/02:00 do %batch.rLaunch a script after a delay :
in 10 mn do %batch.r in 3 hours do %batch.rDefine recurring jobs :
every minute do %job.r every 2 days do %job.r every 2 days not sunday at 13:00 do %job.r every day not [sat sun] 20 times do %job.r every month on #15 not [sat sun] do %job.r every [#01 - #07 #21 - #27 sunday] do %job.r every 15 mn [08:00 - 08:20 12:00 - 20:00] from 02:30 do %job.rAction can also be a function call or a remote action using a URL
in 10 mn do my-function in 3 hours do http://softinnov.org/backup.rspSyntax
<...> designates optional parts.
- Event at a precise point in time
<name:> AT time! DO action
<name:> IN <n> <unit> DO action
<name:> EVERY <n> <unit> <allowed> <NOT forbidden> <FROM moment> <AT time> <t TIMES> DO actionDefinitions :
<name:>: set-word! value for naming the task <n>: integer! value for unit multiplying. <unit>: any of s|sec|second|seconds mn|minute|minutes h|hour|hours d|day|days w|week|weeks m|month|months <allowed>: time (00:00:00), calendar day (#dd), weekday (mon|monday), month (jan|january), range of time|calendar-days, or block of any of theses options. <forbidden>: same options as <allowed> <moment>: date! or time! value <time>: time! value. <t>: integer! value (number of repetition) action: file!|url!|block!|function!|word! value to be evaluated when event is firedSyntactic sugar
Default dialect is parsed in BLOCK! mode. That means that only REBOL values are accepted, but some may want to write calendar dates like: 1st, 2nd,... instead or #1, #2,...
So, a preprocessor has been included requiring tasks to be passed as STRING! values to extend the accepted syntax for the following cases :
Day of month: 1st, 2nd, 3rd, 4th, 5th... Units: 12s, 12mn, 12h, 12d,...Examples using extended string! syntax:
scheduler/plan "every 12h" scheduler/plan "every month not [1st 2nd 3rd 5th]" scheduler/plan "every 15mn not [00:00 - 05:00]"
Just add the following line to your application :
do %scheduler.rthen you can call any of the scheduler's library API like :
Adds one or more jobs to the scheduler. specs describes jobs using the scheduler dialect describe above. Existing scheduled jobs are not changed
Clear the current scheduled jobs, then adds one or more jobs to the scheduler. specs describes jobs using the scheduler dialect describe above.
Removes the named job from the scheduler.
Provides an adequate global event loop for running the scheduler. This is a blocking call that will only return when all the jobs have been done.
- v.0.9.0 - 26-Aug-2009
- First public release.