Skip to main content

Jobs

A job is one thing the dashboard asks one host to do: restart it, apply patches, run a script (see Scripts), restart a service. Everything that changes a host goes through the same engine, so every action has the same states, the same permission checks, the same audit trail and the same live output.

A host that reports a restart pending can be restarted without opening the Jobs tab: with the Restart pending badge in its header, Restart host in its ⋯ menu, or the Hosts list of Patching; that is the same reboot job.

Jobs are listed on the Jobs tab of a host's page. A request for several hosts at once is a batch; its page lists the jobs of all its hosts and how far each has come.

The jobs overview​

Infrastructure > Jobs (/jobs) lists every job you can see, newest first, and follows the server as jobs are sent, started and finished. Filter by status, job type, customer (where you reach more than one) and operating system, or search by job type, host name or batch title; the filters are in the address, so a filtered view can be bookmarked. Each row shows the host with its operating system, the customer, who asked for it and when, a link to its batch and the same actions as on a host's tab: approve or confirm, read the output, cancel, run again, restore SSH keys. The inbox links to the jobs awaiting approval, and the tiles of the home page to the failed ones.

Cancelling all waiting jobs​

Cancel all waiting appears above the list, on the overview and on a batch's page, when the list holds jobs that have not reached their host. It ends every job that is Awaiting approval or Queued in the current list: with a filter set, only the jobs the filter shows. The button names how many that is, and the confirmation repeats it.

  • Jobs that were Sent or are Running are never touched; stopping those asks the host and cannot be taken back, so each is cancelled from its own row.
  • Only jobs you may cancel are counted: the permission for the job type at the job's customer applies as for a single cancel (see the table above).
  • Every cancelled job gets its own Job cancelled entry in the audit log, marked as part of a bulk cancel.
  • A job that moved on while you confirmed (approved and sent, say) is left as it is; the message afterwards says how many were cancelled and how many were not.

What it takes for a job to run​

  1. Someone with the right permission asks for it. The permission depends on the job type, and is checked for the customer the host belongs to:

    Job typePermission to run and cancelPermission to approve
    rebootscript.runscript.run
    script.*script.runscript.run
    service.*service.manageservice.manage
    discovery.*script.runscript.run
    patch.*patch.approvepatch.approve
    defender.*service.manageservice.manage
    ssh.key.*access.shellaccess.shell
    account.*access.shellaccess.shell

    The SSH key jobs are ssh.key.add, ssh.key.remove and ssh.key.restore, see SSH Keys; the account jobs are account.ensure and account.remove, see Server account jobs. A job type that is not in this table cannot be submitted at all. Access to customers still applies: a user only sees and acts on jobs of customers they can reach, see Users and Permissions.

  2. The job is signed. The dashboard never signs a job itself in production: it asks the gateway (see below), which applies limits of its own.

  3. The host is linked. Jobs travel over the live link each agent keeps open to the dashboard. A job for a host that is offline waits in the queue and is sent as soon as the host links.

  4. The agent checks the job. It verifies the signature against the key pinned in its configuration file, that the job is meant for this host, that it has not expired or been seen before, and that the host's configuration file allows the action. A job that fails a check ends as Rejected by host. The actions list in the host's config.yaml names what it allows; a host that lists nothing runs nothing.

Statuses​

StatusMeaning
Awaiting approvalThe job has to be approved or confirmed before it is sent.
QueuedReady, waiting for its host to be linked, for its start time, for its maintenance window or for a free slot in its batch.
SentHanded to the host; the host has not started it yet.
RunningThe host is executing it.
SucceededThe host reports success.
FailedThe host reports failure, or the dashboard could not sign the job. The reason is shown on the row.
Timed outThe host stopped the job at its time limit, or never reported a result for a job that was running.
CancelledStopped by a person before or while it ran.
Rejected by hostThe host refused to start it; see step 4 above.
ExpiredNot sent in time, see below.

A finished job never changes again. To try again, use Run again: it creates a new job with the same parameters in the same batch, and the old record stays as it ended.

Service jobs​

service.start, service.stop and service.restart act on one service of one host. The job carries the service's name and nothing else; the agent runs it through the host's own service manager:

HostStartStopRestart
Linux (systemd)systemctl startsystemctl stopsystemctl restart
Windowssc.exe start, then waits for runningsc.exe stop, then waits for stoppedRestart-Service

The host's config.yaml has to allow the service action. Only services are controlled: on Linux a name ending in anything but .service (a target, a socket, a timer, a mount) is refused, and a name that could be read as an option or carry a second command is refused on both platforms before anything runs. The systemd units that reboot, power off, suspend or isolate the host (systemd-reboot, systemd-poweroff, systemd-halt, systemd-kexec, systemd-soft-reboot, the sleep units, rescue, emergency, exit) are refused as well: restarting a host is the reboot action's business. Starting a service that runs and stopping one that is stopped succeed. A Windows service that does not reach the state within a minute fails the job with the state it is stuck in.

The service control, on the host's Overview tab and the Services tab of its Edit host dialog, lists the services its agent watches (the units named in the systemd collector's settings, and the Windows services in the services collector's) with their state and the buttons that make sense for it. They are offered to whoever holds service.manage at the customer, while the host has a live link and its agent announced the job type. Stopping asks for confirmation. Where the customer's policy asks for a reason, every action does, and the reason is kept in the audit log. A request is valid for 15 minutes: a service request that cannot be carried out soon is not wanted later. Only a service the agent reports can be named, so the buttons cannot reach an arbitrary unit. Each request is written to the audit log as service control, besides the job's own entries.

Jobs that self-healing starts are ordinary script.run jobs with the rule's name as the batch title and no person as requester.

Defender jobs​

defender.quick_scan runs a Microsoft Defender quick scan on a Windows host and reports how many detections it made; defender.update_signatures fetches the newest definitions and reports the version before and after. Both fail with a clear message on a host without Defender. A quick scan can take up to an hour, a signature update up to 15 minutes.

Run them from Security > Endpoint protection: each host with Defender has a Quick scan and an Update definitions button, shown to users who hold service.manage at the customer. The job is sent as a batch of one host and appears on the host's Jobs tab like any other. They can also be submitted through the API (POST /api/jobs).

The host must list defender in the actions of its config.yaml; without it the agent refuses the job. See Agent Installation.

Server account jobs​

Three job types manage logins on Linux hosts; Windows hosts fail them with "not supported on Windows". They need agent 3.3.5 or later. They are sent from the Accounts tab and the key actions on the SSH keys page, see SSH Keys, and can be submitted through the API (POST /api/jobs).

Job typeAction the host must allowWhat it does
ssh.key.addssh-keysadds public keys to an existing account's authorized_keys; mode exact removes all others. Result: file, keys added and removed, backup copy
account.ensureaccountscreates the account or takes over an existing one, sets sudo, the password hash and the keys. Result: created, unlocked, sudo, password set, keys added and removed
account.removeaccountskeys empties the account's authorized_keys, lock locks and expires the account, delete deletes it (and the home directory only when asked)

Each needs access.shell at the host's customer to run, cancel and approve. The host lists the action in the actions of its config.yaml; accounts is in no default set and has to be named where Selvara may manage accounts, see Agent Installation. A host that does not list it ends the job as Rejected by host. Password hashes travel inside the signed job; the agent accepts only a SHA-512-crypt hash and checks names and keys before it changes anything.

Approval​

A job can be submitted so that it waits for approval, and some wait on their own, such as a patch run whose dry run would remove packages. Anyone with the approval permission for that job type at that customer releases it, the person who asked for it included: where nothing but the hold itself asks for it, the approval is a confirmation (Confirm in the job list). A second person is required only where the customer's Require approval (four-eyes) policy is on; there the requester is refused, and if the requester's account has since been deleted, anyone with the permission may approve. The policy is read when the job is released, so turning it on also applies to jobs that are already waiting. Every approval is written to the audit log, marked when the requester confirmed their own job, and so is every refused attempt to approve one's own job under four eyes.

A customer's approval policy is read again when a job is retried: a job that ran without approval before the policy was turned on waits for approval when it is retried afterwards. A retry is also refused for a host that is waiting for approval itself or is not an agent.

Jobs that an assistant submits through the MCP server always wait for approval, whatever the customer's policy says. A command job shows its full command, its language and the reason given for it in the approval dialog, and a retry of it waits again.

Expiry​

Every job has a validity, 24 hours by default (between one minute and seven days when submitted through the API). A job that has not been sent by then ends as Expired, and the host would refuse it anyway: the validity is part of what is signed. The host is never shown more than a day: a job given a longer validity is held by the dashboard until its own deadline, and the expiry it is signed with is a day after it is sent. A job that is scheduled for later is counted from its start time, so a job for tonight is not already expired when tonight comes.

A job that was already sent when it expired is not given up at once: the host accepted it while it was valid and may be waiting for a free slot. It gets a further 15 minutes to report.

Batches, start times and windows​

  • A batch runs at most 10 jobs at a time by default, so a batch over a cluster never takes every node down at once. The limit can be set when the batch is submitted.
  • A job can have a not before time. It is sent at that moment, not earlier.
  • A job can require a maintenance window. It is sent only while that window is open and otherwise waits for it; see Maintenance Windows.

Alerts while a job runs​

A job can be submitted so that it holds back alerts for its host (the Restart host button does). When the host starts the job, the dashboard puts the host into a maintenance window of its own named after the batch, and ends that window when the job is over. For a restart it stays open for up to 15 minutes after the job succeeded, and ends early as soon as the host links again.

Nothing special happens after the window has closed: if the host did not come back healthy, its alerts are raised like on any other day.

Output​

The host streams what the job prints while it runs, and the output viewer on the job's row follows it live. At most 1 MB is kept per job; anything past that is cut off. Only the end of the output is shown in the viewer, and the whole of it can be downloaded. Seeing a job's output needs the same permission as running that job type, since it can contain whatever the job printed.

Output is deleted 90 days after the job finished. The job's own record stays. Change the period under Settings → Data retention; 0 keeps output until the job is deleted. The cleanup runs once an hour.

Signing​

Hosts only run jobs that are signed with a key they know. In production the key is held by selvara-gateway, a separate service, so a dashboard that has been taken over cannot sign jobs by itself.

VariablePurpose
GATEWAY_URLWhere the gateway listens. When it is set, every job is signed there.
GATEWAY_TOKENThe shared secret the dashboard presents to the gateway. Required together with GATEWAY_URL.
JOB_SIGNING_SEEDA base64-encoded 32-byte Ed25519 seed. For development only. The dashboard signs locally with it when no gateway is configured.

The dashboard refuses to sign with JOB_SIGNING_SEED when NODE_ENV is production: every job then fails with the reason shown on its row. A gateway that refuses a job (for instance a job type it does not sign) also fails the job. A gateway that cannot be reached leaves the job queued; it is tried again every 30 seconds, all together, and the log carries one line per attempt rather than one per change.

The public key that matches the signing key is what an agent pins as job_key in its configuration file when it is installed.

A host reports a job over its live link: started, output chunks, finished. Those messages are numbered, the dashboard acknowledges them once it has taken them over, and the agent keeps what is not acknowledged and sends it again after a reconnect. A restart of the database, Redis or the app, or a cut connection, therefore does not lose output or the result; the dashboard applies a host's messages in the order they were sent and tries again while the database is out. Output past the 1 MiB a job may forward is still dropped, as before.

  • A job the host no longer runs ends as failed ("The host no longer runs this job: it restarted, or its result never arrived"). The first message of every link lists the jobs the host still runs or has yet to report; a job the dashboard holds as running that is not on the list ended with a reboot or a restart of the agent, and never will report. The agent cannot rerun it: the job's envelope was accepted once.
  • A job that never reached the host is sent again. A job sent shortly before a link or the dashboard instance holding it went down may have been lost on its way. When the host links again and does not list it, it goes back to Queued and is signed and sent once more; the host never accepted the first one, so it does not run twice.
  • An update of the agent while a job runs ends the job. The job runs in the agent's process, so a restart stops it, and the dashboard ends it as failed with the reason above. Check the host before running the job again.
  • A cancel for a job the host does not know is answered by the host as cancelled, so the job leaves running instead of waiting for a result that cannot come.
  • The last chunk of output is stored: a job's final output is applied before its result, whatever the order the dashboard's workers got to them in.

Troubleshooting​

  • A job stays queued. Check that the host is online and that its agent has a job_key in its configuration file; a host without one does not hold a link. A job with a start time or a maintenance window says so on its row.
  • A job fails at once with "no job signer". Neither GATEWAY_URL nor, in development, JOB_SIGNING_SEED is set.
  • A job ends as rejected. The host's configuration file does not allow the action (actions in the agent's config.yaml), or its clock is far off.
  • A restart shows as succeeded while the host is still up. Success means the restart was scheduled: the host goes down about a minute later so that it can report back first.