For the complete documentation index, see llms.txt. This page is also available as Markdown.

Cron

Definition

A private cron plugin contains user-defined logic that runs periodically, based on a frequency set by the user.

Required files

As stated before, any plugin type, and particularly a private cron plugin, follows this file structure:

β”œβ”€β”€ src
β”‚   β”œβ”€β”€ control     
β”‚   β”œβ”€β”€ function
β”‚   β”œβ”€β”€ view.xml
β”œβ”€β”€ LICENSE
β”œβ”€β”€ README.md 
β”œβ”€β”€ manifest.toml 

control

This is a script written in either Python or NodeJS. Think of it as a setup script, since it runs only once when the plugin is created.

function

This is a script written in either Python or NodeJS. It runs according to the defined frequency.

view.xml

This file lets the developer build and display a form where users can enter the parameters required by the plugin.

The form is displayed when the cron plugin is being created.

For example, consider a plugin that requires the following information from the user:

  • The geographical location of a device.

  • The execution period of the plugin.

  • An Ubidots token.

The form could look like this:

The developer can create a form that displays those fields by using view.xml, as shown below:

All of these form parameters are accessible to the function and control scripts on each execution through the _parameters key in the incoming JSON object.

For detailed information about the supported elements in the view.xml file, refer to its dedicated section in the Plugins development page.

LICENSE and README.md

Refer to the Private Plugins page for more information:

Private plugins

Manifest.toml

Aside from the manifest components common to all plugin types, the following are specific to cron plugins:

Section
Key
Value
Description
Example

[settings]

runtime

Any Python or NodeJS valid version.

This is the environment in which the plugin will run.

runtime = "python:3.7"

[settings.cron]

interval

Any integer number, T, in the range: 1 < T < y. This value is in minutes.

Default frequency at which the plugin will be executed.

interval = 1

[settings.cron]

run_on_deploy*

true or false

Determines if the plugin will be executed immediately upon creation

run_on_deploy = false

With that in mind, a typical manifest.toml file for a private cron plugin looks like this:

Manifest file keys marked with a * are optional and can be omitted.

Naming convention

You must use the names of all files and directories listed in the Required files section, since the plugins engine specifically looks for these files and their extensions.

For instance:

  • If your plugin uses Python as its runtime, the script names should be control.py and function.py

  • If your plugin uses NodeJS as its runtime, the script names should be control.js and function.js

The language selected for the control and function scripts must match the value of the runtime key in the manifest.toml file.

Last updated

Was this helpful?