Skip to content

task

Tasks are operations executed on devices — they are produced by many flows (ndcli sync apply, VPN configuration, backup runs, recurring scheduled tasks, and user-initiated runs via ndcli run). The task command surface is for inspecting and cancelling them. To issue a command to one or more devices, use ndcli run. To manage recurring tasks, use ndcli schedule tasks.

TypeDescription
PINGCheck device connectivity (issued by ndcli run ping)
SHUTDOWNPower off the device (issued by ndcli run poweroff)
REBOOTReboot the device (issued by ndcli run restart)
RESTARTRestart the NetDefense agent service (issued by ndcli run plugin-reload)
PLUGIN_INSTALL(Re)install the NetDefense agent plugin (issued by ndcli run plugin-install)
FIRMWARE_UPGRADEUpgrade the device’s OPNsense firmware — a minor point release or a major series jump (issued by ndcli run firmware-upgrade)
PULLPull configuration from device
SYNCSync configuration to device
BACKUPRun a configured backup
CONNECTOpen a remote-access tunnel session to the device
StatusDescription
PENDINGTask created and waiting for dispatch
SCHEDULEDTask deferred via --at; activates when its time arrives
IN_PROGRESSTask currently executing on the device
COMPLETEDTask completed successfully
FAILEDTask failed
CANCELEDTask was cancelled before dispatch
EXPIREDTask expired before the device picked it up

Note the spelling: the status value is CANCELED, with a single L. From ndcli 1.36.0, --status also accepts CANCELLED.

NetDefense automatically removes finished tasks (COMPLETED, FAILED, EXPIRED and CANCELED) after 30 days. More precisely, a finished task is removed once its creation time, its expiry time and its last update are all more than 30 days in the past. PENDING, SCHEDULED and IN_PROGRESS tasks are never removed. Removal runs in the background about once an hour, so a task can stay visible a little past the 30 days.

Once removed, a task no longer appears in ndcli task list, on the Tasks page in NDWeb or on the dashboard, and looking up its task code returns “not found”. Removing a BACKUP task leaves its backup alone: backup files live in your organization’s own storage, and NetDefense does not delete them. Recurring scheduled tasks and their schedules are not affected either.

CommandDescription
task listList tasks
task describeShow task details
task cancelCancel a pending or scheduled task

List tasks in your organization.

Terminal window
ndcli task list [flags]
FlagTypeDefaultDescription
--devicestringFilter by device name (regex)
--statusstringFilter by status. For several values, repeat the flag or separate them with commas (e.g., --status FAILED --status EXPIRED); that needs ndcli 1.36.0 or later
--typestringFilter by task type. For several values, repeat the flag or separate them with commas (e.g., --type SYNC --type BACKUP); that needs ndcli 1.36.0 or later
--expiredboolFilter by expired status
--created-afterstringFilter by created date
--created-beforestringFilter by created date
--sort-bystringcreated_at:descSort field and direction
--pageint1Page number
--per-pageint30Items per page (max 100)

Date filters accept:

  • Relative: 30m, 2h, 7d, 2w (minutes, hours, days, weeks ago)
  • ISO 8601: 2024-01-15T10:30:00Z
Terminal window
ndcli task list
ndcli task list --created-after 1h
ndcli task list --device fw-prod-01
ndcli task list --status FAILED
ndcli task list --type SYNC
ndcli task list --status SCHEDULED --sort-by created_at:asc
# Multi-value: show both FAILED and EXPIRED tasks
ndcli task list --status FAILED --status EXPIRED
# Multi-value: show SYNC and BACKUP tasks from the last 24h
ndcli task list --type SYNC --type BACKUP --created-after 24h

Show detailed information about a specific task.

Terminal window
ndcli task describe [task-id]
ArgumentRequiredDescription
task-idYesTask code (8-char base62)

Shows:

  • Task code and type
  • Target device
  • Status and progress
  • Creation, update, expiry, and (when set) scheduled timestamps
  • Result or error message
Terminal window
ndcli task describe abc12345
ndcli task describe abc12345 -f json
  • Finished tasks are removed after 30 days; looking up a removed task’s code returns “not found”. See Task retention.

Cancel a pending or scheduled task.

Terminal window
ndcli task cancel [task-id]
ArgumentRequiredDescription
task-idYesTask code to cancel
Terminal window
ndcli task cancel abc12345
  • Only tasks with PENDING or SCHEDULED status can be cancelled.
  • Tasks already IN_PROGRESS cannot be cancelled.
  • Cancelled tasks have status CANCELED.