# How to schedule a Telegraf inputs.exec

**URL:** <https://community.influxdata.com/t/how-to-schedule-a-telegraf-inputs-exec/18954>\
**Category:** Telegraf\
**Tags:** telegraf\
**Created:** [March 18, 2021, 11:01am UTC](https://community.influxdata.com/t/how-to-schedule-a-telegraf-inputs-exec/18954 "2021-03-18T11:01:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mpolla](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/mpolla/32/7004_2.png) [@mpolla](https://community.influxdata.com/u/mpolla)\
**Post date:** [March 18, 2021, 11:01am UTC](https://community.influxdata.com/t/how-to-schedule-a-telegraf-inputs-exec/18954/1 "2021-03-18T11:01:46Z")

</div>

I’m collecting data that updates only once a day at 12 AM. Instead of polling for new data using a short `interval` I would like to schedule the inputs.exec execution using a cron-like schedule such as `1 12 * * * `. Is there a workaround for this?

---

<div class="post-metadata">

**Author:** ![Franky1](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/franky1/32/6666_2.png) [@Franky1](https://community.influxdata.com/u/Franky1)\
**Post date:** [March 18, 2021, 11:16am UTC](https://community.influxdata.com/t/how-to-schedule-a-telegraf-inputs-exec/18954/2 "2021-03-18T11:16:01Z")

</div>

The plugin does not have to be executed with the global interval of the agent.  
You can set an individual interval for each plugin.

> **[Configuring Telegraf | Telegraf 1.21 Documentation](https://docs.influxdata.com/telegraf/v1.18/administration/configuration/#input-configuration)**
>
> Overview of the Telegraf configuration file, enabling plugins, and setting environment variables.

```plaintext
[[inputs.exec]]
  interval = "24h"

```

* * *

Other possibilities that came to my mind spontaneously would be:

1. Query the current time in your custom exec plugin with `time.now()` (in your programming language) and return a metric to telegraf only once a day.

2. Execute a separate script with a cron job once a day and send the result e.g. to the telegraf plugin `inputs.socket_listener` or `inputs.tail`

* * *

Unfortunately, as far as I know, Telegraf does not yet offer the possibility to define an `interval` with the **cron** syntax.  
But maybe that will come in the future?  
Would it be worth a feature request?

Edit: Yes 😉

> <https://github.com/influxdata/telegraf/issues/9010>
>
> \## Feature Request
> 
> Add cron syntax for interval
> 
> \### Proposal:
> 
> Add \*\*cro…n\*\* syntax for \`interval\` or introduce a new keyword \`cron\` that can be used (instead of interval) in the agent or plugins config.
> 
> \### Current behavior:
> 
> Not implemented
> 
> \### Desired behavior:
> 
> cron syntax possible for interval or a new keyword \`cron\` that can be used in the agent or plugins config.
> 
> \### Use case: 
> 
> Query metrics at defined points in time instead of at intervals.
