← All procedures

schedule.add

Add a schedule: a cron expression that starts a stored program with an input

CLI
Package
@procedures/schedule · README
Path
["schedule","add"]
CLI
mark schedule add --cron <string> --program <string>
As data
{"$proc":["schedule","add"],"input":{}}
Tags
schedule, cron, programs

Use it

In TypeScript

import { Client, LocalTransport, PROCEDURE_REGISTRY } from "@procedures/client";
import "@procedures/schedule/register"; // registers its procedures

const client = new Client(new LocalTransport({ registry: PROCEDURE_REGISTRY }));
const result = await client.exec(["schedule","add"], { cron: "<cron>", program: "<program>" });
console.log(JSON.stringify(result));

From the command line

$ mark schedule add --cron <string> --program <string>

As data, in a program

{
  "$proc": ["schedule", "add"],
  "input": { "cron": "<cron>", "program": "<program>" }
}

Input

FieldTypeRequiredDefaultDescription
idstringnoThe name of the schedule (default: the key of the program)
cronstringyesThe cron expression: 5 fields (minute hour day month weekday), or @hourly, @daily, @weekly, @monthly, @yearly
programstringyesThe dotted key of the stored program
inputanynoThe input of the program
timeZonestringnoThe time zone of the expression: utc, local (default) or an IANA name such as Europe/Berlin
replacebooleannoTrue: replace a schedule of the same name (default false)

Output

FieldTypeRequiredDefaultDescription
scheduleobjectyes
JSON Schemas
{
  "input": {
    "type": "object",
    "properties": {
      "id": {
        "description": "The name of the schedule (default: the key of the program)",
        "type": "string",
        "pattern": "^[A-Za-z0-9._:-]{1,200}$"
      },
      "cron": {
        "type": "string",
        "minLength": 1,
        "maxLength": 200,
        "description": "The cron expression: 5 fields (minute hour day month weekday), or @hourly, @daily, @weekly, @monthly, @yearly"
      },
      "program": {
        "type": "string",
        "maxLength": 500,
        "pattern": "^[^.\\s]+(\\.[^.\\s]+)*$",
        "description": "The dotted key of the stored program"
      },
      "input": {
        "description": "The input of the program"
      },
      "timeZone": {
        "type": "string",
        "minLength": 1,
        "maxLength": 100,
        "description": "The time zone of the expression: utc, local (default) or an IANA name such as Europe/Berlin"
      },
      "replace": {
        "description": "True: replace a schedule of the same name (default false)",
        "type": "boolean"
      }
    },
    "required": [
      "cron",
      "program"
    ]
  },
  "output": {
    "type": "object",
    "properties": {
      "schedule": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "cron": {
            "type": "string"
          },
          "program": {
            "type": "string"
          },
          "input": {},
          "timeZone": {
            "type": "string",
            "description": "The time zone: utc, local or an IANA name"
          },
          "createdAt": {
            "type": "number",
            "description": "When the schedule was added, in milliseconds since 1970"
          },
          "capability": {
            "description": "The capability of the caller that added it: its clearance and its permitted effects"
          },
          "lastRun": {
            "description": "The last run",
            "type": "object",
            "properties": {
              "startedAt": {
                "type": "number",
                "description": "The start, in milliseconds since 1970"
              },
              "durationMs": {
                "type": "number"
              },
              "outcome": {
                "type": "string",
                "enum": [
                  "success",
                  "failure"
                ]
              },
              "error": {
                "type": "object",
                "properties": {
                  "code": {
                    "type": "string"
                  },
                  "message": {
                    "type": "string"
                  }
                },
                "required": [
                  "message"
                ],
                "additionalProperties": false
              }
            },
            "required": [
              "startedAt",
              "durationMs",
              "outcome"
            ],
            "additionalProperties": false
          },
          "runs": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "failures": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991
          },
          "skipped": {
            "type": "integer",
            "minimum": -9007199254740991,
            "maximum": 9007199254740991,
            "description": "The times that came during a run: no second run started"
          },
          "nextRunAt": {
            "description": "The next time as an ISO text, or null",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "id",
          "cron",
          "program",
          "timeZone",
          "createdAt",
          "runs",
          "failures",
          "skipped",
          "nextRunAt"
        ],
        "additionalProperties": false
      }
    },
    "required": [
      "schedule"
    ],
    "additionalProperties": false
  }
}