Plugin: Scheduler

Timers and scheduled jobs

Scheduled Jobs

A scheduled job triggers periodically using a cron expression.

Cron Expression

Comma separated values such as 5,8,10 represent more than one time value. So for example, a schedule of 0 2,14,26 * * * * would execute on the 2nd, 14th, and 26th minute of every hour.

Ranges can be specified with a dash. A schedule of 0 0 * 5-10 * * would execute once per hour but only on day 5 through 10 of the month.

Day of the week can be specified as an abbreviation or the full name. A schedule of 0 0 6 * * Sun,Sat would execute at 6am on Sunday and Saturday.

Note that the year may be omitted.

Examples

Cron Expressionsecminhourday of monthmonthday of weekyearDescription
* * * * * * ********Runs every second
0 2,14,26 * * * *02,14,26****Run once per hour but only on day 5 through 10 of the month
0 0 * 5-10 * *00*5-10**Run at 6am on Sunday and Saturday

Timers

A timer triggers after a given duration. The duration can be specified either as a number in milliseconds or as a string in ISO 8601 Duration Format.

ISO 8601 Duration Format

What is the ISO 8601 Duration Format?

Durations define the amount of intervening time in a time interval and are represented by the format P[n]Y[n]M[n]DT[n]H[n]M[n]S or P[n]W. In these representations, the [n] is replaced by the value for each of the date and time elements that follow the [n]. Leading zeros are not required, but the maximum number of digits for each element should be agreed to by the communicating parties. The capital letters P, Y, M, W, D, T, H, M, and S are designators for each of the date and time elements and are not replaced.

https://en.wikipedia.org/wiki/ISO_8601#Durations

Designators

DesignatorDescription
PP is the duration designator (for period) placed at the start of the duration representation.
YY is the year designator that follows the value for the number of years.
MM is the month designator that follows the value for the number of months.
WW is the week designator that follows the value for the number of weeks.
DD is the day designator that follows the value for the number of days.
TT is the time designator that precedes the time components of the representation.
HH is the hour designator that follows the value for the number of hours.
MM is the minute designator that follows the value for the number of minutes.
SS is the second designator that follows the value for the number of seconds.

Examples

DurationDescription
PT10SRepresents a duration of ten seconds.
PT1M30SRepresents a duration of one minute and thirty seconds.
PT1HRepresents a duration of one hour.
P1DT12HRepresents a duration of one day and twelve hours.
P3Y6M4DT12H30M5SRepresents a duration of three years, six months, four days, twelve hours, thirty minutes, and five seconds.

Entity Types

NameComponentPropertyData TypeSocket TypeDescription
scheduled_jobschedulestringinputCron Expression
generatortriggerbooloutput
timerdurationnumber
or
string
inputDuration in milliseconds or as ISO8601 Duration Format
generatortriggerbooloutput

Platform Compatibility

PlatformCompatibility
Linux
MacOS
Windows

Repositories

Usage

Usage

GraphQL: Create a new timer

mutation {
  instances {
    entities {
      create(
        type: "timer",
        id: "46e2ecd0-3e91-4205-99c9-d9543923a73a",
        properties: [
          {
            name: "duration",
            value: 1000
          }
        ]
      ) {
        id
        type {
          name
        }
        properties(
          names: [
            "duration",
            "trigger"
          ]
        ) {
          name
          value
        }
      }
    }
  }
}

GraphQL: Update duration of an existing timer

mutation {
  instances {
    entities {
      update(
        id: "46e2ecd0-3e91-4205-99c9-d9543923a73a",
        properties: [
          {
            name: "duration",
            value: 1500
          }
        ]
      ) {
        id
        type {
          name
        }
        properties(
          names: [
            "duration",
            "trigger"
          ]
        ) {
          name
          value
        }
      }
    }
  }
}