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-timesor--run-frequencymay be provided (not both). - Only one of
--day-of-weekor--ordinal-daymay be provided (not both).
๐ฅ๏ธ Basic Usage¶
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"
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
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"
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"
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"
Create an inactive task¶
easytask tasks create \
--name "maintenance_job" \
--cmd "echo disabled" \
--host "localhost" \
--inactive
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"
}