Skip to content

Create Task

The tasks create command creates a new task from inline parameters or a JSON definition file.

Modes

Mode When to Use
Inline Quick one-off tasks โ€” pass all fields as CLI flags.
File (--file) Complex or repeatable definitions โ€” provide a JSON file.

Both modes are mutually exclusive. If --file is provided, all inline parameters are ignored.

Parameters

File Mode

Parameter Description
--file, -f JSON file with task definition.

Inline Parameters

Parameter Required Description
--name, -n Yes Task name.
--cmd, -c Yes Command to run.
--host Yes Agent hostname (e.g. localhost).
--description, -d No Task description.
--active / --inactive No Active status (default: --active).
--group-id, -g No Group ID to assign the task to.
--timezone, -z No Timezone in IANA format (e.g. UTC, America/New_York).
--trigger-times No Comma-separated times in HH:MM format (e.g. 09:00,14:30). Automatically deduplicated and sorted.
--day-of-week No 7-character binary string for MTWTFSS (e.g. 1111100 = Monโ€“Fri).
--ordinal-day No Ordinal day description (e.g. first monday of every month).
--run-frequency No Run frequency in HH:MM-HH:MM-freq format (e.g. 00:00-23:59-60).
--calendar No Calendar name (must exist in the backend).
--dependency No Dependency string (e.g. S:taskname).
--max-run-time No Maximum run time in seconds (1โ€“172800).
--retry-attempts No Number of retry attempts on failure.
--stdout No File path for stdout capture.
--stderr No File path for stderr capture.
--profile No Profile name.
--task-owner No Task owner.
--run-as-user No System user to run the command as.

Mutual Exclusivity

  • Only one of --trigger-times or --run-frequency may be provided (not both).
  • Only one of --day-of-week or --ordinal-day may be provided (not both).

๐Ÿ–ฅ๏ธ Basic Usage

easytask tasks create -h
 Usage: easytask tasks create [OPTIONS]

 Create a task from inline parameters or a JSON file.

โ•ญโ”€ Options โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ --file            -f      PATH     JSON file with task definition               โ”‚
โ”‚ --name            -n      TEXT     Task name (required if no --file)             โ”‚
โ”‚ --cmd             -c      TEXT     Command to run (required if no --file)        โ”‚
โ”‚ --host                    TEXT     Agent hostname (required if no --file)        โ”‚
โ”‚ --description     -d      TEXT     Task description                             โ”‚
โ”‚ --run-as-user              TEXT     Run as user                                 โ”‚
โ”‚ --active / --inactive               Active status (default: active)             โ”‚
โ”‚ --group-id        -g      INT      Group ID                                    โ”‚
โ”‚ --timezone        -z      TEXT     Timezone, e.g. UTC                          โ”‚
โ”‚ --trigger-times            TEXT     Comma-separated HH:MM                       โ”‚
โ”‚ --day-of-week              TEXT     7-char binary MTWTFSS                       โ”‚
โ”‚ --ordinal-day              TEXT     Ordinal day                                โ”‚
โ”‚ --run-frequency            TEXT     HH:MM-HH:MM-freq                           โ”‚
โ”‚ --calendar                 TEXT     Calendar name                              โ”‚
โ”‚ --dependency               TEXT     Dependency string                           โ”‚
โ”‚ --max-run-time             INT      Max run time in seconds                    โ”‚
โ”‚ --retry-attempts           INT      Retry attempts                             โ”‚
โ”‚ --stdout                   TEXT     Stdout file path                           โ”‚
โ”‚ --stderr                   TEXT     Stderr file path                           โ”‚
โ”‚ --profile                  TEXT     Profile name                               โ”‚
โ”‚ --task-owner               TEXT     Task owner                                 โ”‚
โ”‚ --help             -h               Show this message and exit.                 โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Inline Mode Examples

Create a basic task

easytask tasks create --name "data_processing" --cmd "/usr/bin/python3 /scripts/process.py" --host "worker-01"
Task created with ID: 42

Create a task with schedule

easytask tasks create \
  --name "daily_report" \
  --cmd "/opt/reports/daily.sh" \
  --host "localhost" \
  --description "Daily report generation" \
  --trigger-times "09:00" \
  --day-of-week "1111100" \
  --timezone "UTC" \
  --max-run-time 3600 \
  --retry-attempts 3
Task created with ID: 43

Create a task with multiple trigger times

Trigger times are automatically deduplicated and sorted:

easytask tasks create \
  --name "multi_check" \
  --cmd "python check.py" \
  --host "localhost" \
  --trigger-times "22:00,06:00,14:00" \
  --day-of-week "1111111" \
  --timezone "UTC"
Task created with ID: 44

Create a task with run frequency

easytask tasks create \
  --name "frequent_pulse" \
  --cmd "watch -n 1 echo pulse" \
  --host "localhost" \
  --run-frequency "00:00-23:59-120" \
  --day-of-week "1000001" \
  --timezone "Europe/London"
Task created with ID: 45

Create a task in a group with dependency

easytask tasks create \
  --name "report_notify" \
  --cmd "python notify.py" \
  --host "localhost" \
  --group-id 1 \
  --dependency "S:daily_report" \
  --run-as-user "appuser"
Task created with ID: 46

Create an inactive task

easytask tasks create \
  --name "maintenance_job" \
  --cmd "echo disabled" \
  --host "localhost" \
  --inactive
Task created with ID: 47

File Mode Examples

Task Schema

{
  "name": "data_processing",
  "task_owner": "admin",
  "cmd": "/usr/bin/python3 /scripts/process.py",
  "run_on_host": "worker-01",
  "description": "Daily data processing task",
  "stderr": "/var/log/easytask/data_processing.err",
  "stdout": "/var/log/easytask/data_processing.out",
  "timezone": "UTC",
  "active": true,
  "instance": "default",
  "day_of_week": "1111100",
  "trigger_times": "08:00",
  "run_as_user": "easytask",
  "max_run_time": 3600,
  "retry_attempts": 3,
  "calendar": "WORKDAY"
}

Sample Input

task_def.json
{
  "name": "data_processing",
  "task_owner": "admin",
  "cmd": "/usr/bin/python3 /scripts/process.py",
  "run_on_host": "worker-01",
  "description": "Daily data processing task",
  "timezone": "UTC",
  "active": true,
  "day_of_week": "1111100",
  "trigger_times": "08:00"
}

Example

easytask tasks create -f task_def.json
Task created with ID: 42

โญ๏ธ Next Steps