> For the complete documentation index, see [llms.txt](https://dev.ubidots.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev.ubidots.com/plugins/private-plugins/cron.md).

# 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:

<figure><img src="/files/pLxlgGqHXVDhjnkgXjjy" alt="" width="563"><figcaption></figcaption></figure>

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

```xml
<form name="formName">

    <group name="locacionGroup">
        <group name="location">
            <label name="labelLocation">Click on the map to specify a location</label>
            <map name="map" />
        </group>
    </group>

    <group name="unitsGroup">
        <group name="unitsSelect">
            <label name="labelUnits">Units format</label>
            <select
              name="units"
              placeholder="Units format"
              value="metric"
              type="single"
            >
                    <option value="metric">Metric</option>
                    <option value="imperial">Imperial</option>
            </select>
        </group>
    </group>

    <group name="freq">        
        <group name="freqInfo">
            <frequency label="Run every {field} minutes"/>
        </group>
        <label name="labelUnits" help="Please note data is updated every 10 to 20 minutes"></label>
    </group>

    <group name="ubidotsInformation">
        <group name="fieldToken">
            <label name="labelToken">Ubidots Token</label>
            <token name="token" placeholder="Select Token"/>
        </group>
    </group>
</form>
```

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.

{% hint style="info" %}
For detailed information about the supported elements in the `view.xml` file, refer to its dedicated section in the [Plugins development](https://dev.ubidots.com/plugins/plugins-development/view.xml) page.
{% endhint %}

## LICENSE and README.md

Refer to the Private Plugins page for more information:

{% content-ref url="/pages/y6JQhF1KBcDzwb9Vtae2" %}
[Private plugins](/plugins/private-plugins.md)
{% endcontent-ref %}

## Manifest.toml

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

<table data-full-width="true"><thead><tr><th align="center">Section</th><th align="center">Key</th><th align="center">Value</th><th align="center">Description</th><th align="center">Example</th></tr></thead><tbody><tr><td align="center">[settings]</td><td align="center">runtime</td><td align="center">Any Python or NodeJS valid version.</td><td align="center">This is the environment in which the plugin will run.</td><td align="center"><code>runtime = "python:3.7"</code></td></tr><tr><td align="center">[settings.cron]</td><td align="center">interval</td><td align="center">Any integer number, T, in the range:<br>1 &#x3C; T &#x3C; y. This value is in minutes.</td><td align="center">Default frequency at which the plugin will be executed.</td><td align="center"><code>interval = 1</code></td></tr><tr><td align="center">[settings.cron]</td><td align="center">run_on_deploy*</td><td align="center"><em>true</em> or <em>false</em></td><td align="center">Determines if the plugin will be executed immediately upon creation</td><td align="center"><code>run_on_deploy = false</code></td></tr></tbody></table>

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

```
manifest_version = 2.0
 
[settings] 
version = "1.0.56" 
runtime = "nodejs:10" | "python:3.7"
plugin_type = "cron" 
license_name = "MIT license" 

[settings.cron] 
interval = 1 
run_on_deploy = false

[pricing]
price = 0 
```

{% hint style="info" %}
Manifest file keys marked with a \* are optional and can be omitted.
{% endhint %}

## 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`

{% hint style="info" %}
The language selected for the `control` and `function` scripts must match the value of the *`runtime`* key in the `manifest.toml` file.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://dev.ubidots.com/plugins/private-plugins/cron.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
