Skip to content
On this page

Scheduler

Schedule any JSON API request as a single task by editing /var/cache/iqrf-gateway-daemon/scheduler/Tasks.json and restart the daemon.

Since v2.1.0 Tasks.json has been removed and replaced by one json file for single task.

bash
sudo systemctl restart iqrf-gateway-daemon.service

Example

Following example schedules two tasks.

  • first task is queued at 0 sec every 1 min
  • second task is queued at 1 sec also every 1 min
  • time follows Cron format with addition for second resolution.
  • use service SchedulerMessaging
  • choose messaging (MqMessaging, WebsocketMessaging, ** MqttMessaging**) JSON API response will be sent

From v2.1.x

  • Task 1, filename e.g. /var/cache/iqrf-gateway-daemon/scheduler/1.json
json
{
  "taskId": 1,
  "clientId": "SchedulerMessaging",
  "timeSpec": {
    "cronTime": "0 */1 * * * * *",
    "exactTime": false,
    "periodic": false,
    "period": 0,
    "startTime": ""
  },
  "task": {
    "messaging": "MqttMessaging",
    "message": {
      "mType": "iqrfEmbedLedr_Pulse",
      "data": {
        "msgId": "testEmbedLedr",
        "req": {
          "nAdr": 1,
          "param": {}
        },
        "returnVerbose": true
      }
    }
  }
}
  • Task 2, filename e.g. /var/cache/iqrf-gateway-daemon/scheduler/2.json
json
{
  "taskId": 2,
  "clientId": "SchedulerMessaging",
  "timeSpec": {
    "cronTime": "0 */2 * * * * *",
    "exactTime": false,
    "periodic": false,
    "period": 0,
    "startTime": ""
  },
  "task": {
    "messaging": "MqttMessaging",
    "message": {
      "mType": "iqrfEmbedLedr_Pulse",
      "data": {
        "msgId": "testEmbedLedr",
        "req": {
          "nAdr": 2,
          "param": {}
        },
        "returnVerbose": true
      }
    }
  }
}
  • cron time

    • exactTime = false
    • periodic = false
    • cronTime valid
  • periodic time

    • exactTime = false
    • periodic = true
    • period > 0
    • if startTime valid > now => delayed start else now
  • one shot time

    • exactTime = true
    • periodic = false
    • if startTime valid > now => delayed one shot time else ignored
  • N/A

    • exactTime = true
    • periodic = true

CRON nicknames

It is possible to use CRON nicknames for time pattern.

CRON nicknameDescriptionExample
@rebootRun once after reboot.
@yearlyRun once a year.0 0 0 0 1 1 *
@annuallyRun once a year.0 0 0 0 1 1 *
@monthlyRun once a month.0 0 0 0 1 * *
@weeklyRun once a week.0 0 0 * * * 0
@dailyRun once a day.0 0 0 * * * *
@hourlyRun once an hour.0 0 * * * * *
@minutelyRun once a minute.0 * * * * * *

API

Scheduler can be also configured via Scheduler API. Configuration via API is persistent since v2.1.0.

There are examples in C# test app .