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.
LICENSE and README.md
Refer to the Private Plugins page for more information:
Private pluginsManifest.toml
Aside from the manifest components common to all plugin types, the following are specific to cron plugins:
[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:
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.pyandfunction.pyIf your plugin uses NodeJS as its runtime, the script names should be
control.jsandfunction.js
Last updated
Was this helpful?