Creating an InfluxDB OSS v2 task saves a scheduled Flux script that runs inside the server. Use it for recurring rollups, checks, or transformations that run without an external scheduler or client script.

The CLI path uses a saved influx profile, a task file with an option task block, and influx task create with --file. The task file names the schedule and Flux pipeline, and InfluxDB stores the task as active unless the status is changed later.

A one-minute rollup task reads a recent point from factory_metrics and writes the mean value into factory_rollups. Use buckets, tags, and time ranges that match the source data, and test against a scratch bucket when a scheduled task must not modify production series.

Steps to create an InfluxDB v2 task:

  1. Confirm the active influx CLI profile.
    $ influx config list
    Active	Name	URL			Org
    *	default	http://localhost:8086	plant-ops

    The active profile supplies the host, organization, and token for commands that do not include those flags.
    Related: How to configure an InfluxDB v2 CLI profile

  2. Confirm the source and destination buckets.
    $ influx bucket list
    ID			Name		Retention	Shard group duration	Organization ID		Schema Type
    970292dd3da64fe6	_monitoring	168h0m0s	24h0m0s			004477c13d5ded9a	implicit
    f20afdaa80269b26	_tasks		72h0m0s		24h0m0s			004477c13d5ded9a	implicit
    c6488abaee989ea1	factory_metrics	infinite	168h0m0s		004477c13d5ded9a	implicit
    215b75ac8a106f53	factory_rollups	168h0m0s	24h0m0s			004477c13d5ded9a	implicit

    factory_metrics is the source bucket and factory_rollups is the task destination. Create the destination bucket first when it is missing.
    Related: How to create an InfluxDB v2 bucket with retention

  3. Confirm that the source bucket has a recent point for the task range.
    $ influx query 'from(bucket: "factory_metrics") |> range(start: -10m) |> filter(fn: (r) => r._measurement == "temperature") |> keep(columns: ["_time", "_value", "site", "line"])'
    Result: _result
    Table: keys: [line, site]
               line:string             site:string                      _time:time                  _value:float
    ----------------------  ----------------------  ------------------------------  ----------------------------
                    line-a                 plant-1  2026-06-20T10:15:51.951320550Z                          21.7

    If no suitable source point exists, write one to a scratch bucket instead of adding validation data to a production bucket.
    Related: How to write line protocol to InfluxDB v2

  4. Create the Flux task file.
    factory-temperature-rollup.flux
    option task = {
      name: "factory_temperature_rollup",
      every: 1m,
      offset: 0m,
    }
     
    from(bucket: "factory_metrics")
      |> range(start: -10m)
      |> filter(fn: (r) => r._measurement == "temperature")
      |> filter(fn: (r) => r._field == "value")
      |> aggregateWindow(every: 1m, fn: mean, createEmpty: false)
      |> set(key: "_measurement", value: "temperature_rollup")
      |> to(bucket: "factory_rollups", org: "plant-ops")

    name is required. Use either every or cron for the schedule, not both. offset delays execution while keeping the queried time window aligned with the original schedule.

  5. Create the task from the file.
    $ influx task create --org plant-ops --file factory-temperature-rollup.flux
    ID			Name				Organization ID		Organization	Status	Every	Cron	ScriptID
    10e52154cea00000	factory_temperature_rollup	004477c13d5ded9a	plant-ops	active	1m

    active means the task scheduler can run the task at the configured interval.

  6. List the saved task by ID.
    $ influx task list --id 10e52154cea00000
    ID			Name				Organization ID		Organization	Status	Every	Cron	ScriptID
    10e52154cea00000	factory_temperature_rollup	004477c13d5ded9a	plant-ops	active	1m
  7. Check the latest scheduled task run after one interval.
    $ influx task run list --task-id 10e52154cea00000 --limit 1
    ID			TaskID			Status	ScheduledFor		StartedAt			FinishedAt			RequestedAt
    10e521bbf2200000	10e52154cea00000	success	2026-06-20T10:18:00Z	2026-06-20T10:18:00.012678721Z	2026-06-20T10:18:00.023251388Z

    A task that runs every minute usually needs the next minute boundary before the first run appears. Use influx task log list with the task ID when the status is not success.

  8. Query the destination bucket for the task output.
    $ influx query 'from(bucket: "factory_rollups") |> range(start: -20m) |> filter(fn: (r) => r._measurement == "temperature_rollup") |> keep(columns: ["_time", "_value", "site", "line"])'
    Result: _result
    Table: keys: [line, site]
               line:string             site:string                      _time:time                  _value:float
    ----------------------  ----------------------  ------------------------------  ----------------------------
                    line-a                 plant-1  2026-06-20T10:16:00.000000000Z                          21.7

    A returned row from factory_rollups confirms that the saved task ran and wrote data through the configured Flux pipeline.
    Related: How to run a Flux query in InfluxDB v2