Skip to content

Workflows

A workflow is a list of steps that ZestSSH runs one after another: run a command on a host, run a snippet, wait, send yourself a notice. Use one for a deploy, a health check or a routine you run often, and start it with one tap or from another app.

Workflows need Squeezed (see pricing).

  • On a computer: Automation in the side bar, on the Workflows tab. You can build, edit and run workflows there while the Automations on switch at the top is off. That switch is for what starts from outside: links, other apps, API keys and scheduled runs.
  • On a phone: More > Automation > Workflows.

A workflow stays on the device you made it on. Workflows do not sync to your other devices.

With no workflow yet, from 4.3, the Workflows tab is a start page across the whole width, Automate what you do by hand, with no empty editor beside it. It offers four templates, each card showing the steps its workflow holds, a line each, and Use this:

Template What it makes
Update packages on a group “Runs apt on each host, one at a time, and stops at the first failure.” One snippet step on your first group that has hosts (or on your first host, when no group has any), then a notice.
Restart a container “Pick a host and a container.” One snippet step, with a field for the container’s name.
Check disk space everywhere “Tells you when any host is more than 85% full.” One command step on all your hosts, with its own command for BSD and macOS; a full host does not stop the others.
Back up a folder “Copies a folder to another host with rsync over SSH.” One snippet step, with fields for the folder and the destination.

A template is filled in from your own hosts and groups and opens in the editor beside the list, marked “from template”, unsaved. Check its hosts and fields, then choose Save workflow. Every template is set to tell you when it fails.

Three of the templates run a snippet. If you have no snippet of that name, ZestSSH asks, for example, Add the snippet “Update packages”? and shows the command it adds (sudo apt-get update && sudo apt-get -y upgrade). Choose Add snippet to add it to your snippets; without it, the template does not open.

Under the templates, New workflow opens an empty workflow, and Make one from your history builds one from commands you ran: Make a workflow from your history lists this device’s command history, each command once per host, newest first. Tick the commands in the order they should run and choose Use 3 commands. Each becomes a command step on the host it ran on (with no host where that host is no longer saved), and the workflow, named From my history, opens unsaved in the editor. With history off or empty the list says so, and in Recording mode it shows no commands.

The editor opens beside the start page only once you choose one of these. Close it without saving and the start page stands alone again. The page head’s own New workflow waits until a workflow exists.

On a computer:

  1. On the Workflows tab, click New workflow (at the top of the page).
  2. Give it a Name and, if you like, a Description.
  3. Under When it runs, choose Manually (“Runs only when you run it here.”) or API key or link (“Also runs from a zestssh:// link, from another app (Tasker, Shortcuts) or from a phone’s schedule, with an API key.”). A new workflow starts on API key or link.
  4. Under Steps, click Add step and pick the step’s kind: Snippet, Command, Wait or Notify.
  5. For a snippet or a command, pick what it runs on under Runs on: hosts, a group or all hosts. Fill in the rest (see Steps).
  6. Under Advanced in a step, set its Timeout and whether to Continue on error.
  7. Under Tell me, choose When it fails and When it succeeds.
  8. Choose Save workflow.

On a phone:

  1. On Workflows, tap Create workflow (or +).
  2. Fill in Workflow name and, if you like, Description (optional).
  3. Tap Add step and choose Execute command, Run snippet, Delay or Notify.
  4. For a command or a snippet, pick the host under Host. Set the step’s Timeout and its On failure choice.
  5. Under Notifications, choose Notify on success and Notify on failure.
  6. Save.

Drag a step by its handle to move it, on either device. On a phone, each step has a delete button. On a computer, a step’s menu has Duplicate, Disable (or Enable) and Delete. A disabled step is kept but skipped, however the workflow is started. To delete a saved workflow on a computer, use the trash button at the top of its editor.

Runs a command on the step’s host. The step succeeds when the command ends with exit code 0.

Command: cd /srv/app && git pull origin main
Runs on: web-01.example.com
Timeout: 60

On a computer, a command step can have a command for another system: under Advanced, Add a command for another system adds one for Linux, BSD (FreeBSD, OPNsense…), macOS or Windows. A host on that system runs it in place of the step’s own. A host whose system ZestSSH has not seen yet is asked first (uname -s), once in a run however many steps have such commands, and where it says nothing the step’s own command runs.

Runs a saved snippet on the step’s host. The step finds the snippet by its name. If that snippet was renamed or deleted, the step fails and the workflow stops there, whatever the step is set to do when it fails: “The snippet “Update packages” is not in your snippets any more (deleted or renamed), so nothing ran. Choose another snippet for this step.”

On a computer, a snippet step shows a field for each of the snippet’s variables, for example CONTAINER for docker restart ${CONTAINER}. What you type there fills the snippet’s ${NAME} (also ${NAME:-default} and ${NAME:secret}) and {{NAME}} when the step runs, each value written for the place it lands in, inside any quotes the snippet has around it (see Variables). A variable with a default left empty takes its default, at every place it stands.

Some variables need a value: a field left blank, a list or a secret with none, and a plain ${NAME} with no value, or an empty default like ${NAME:-}, where the command would be a dangerous one with it empty. rm -rf ${DIR}/* with DIR blank never reaches a shell. A run you start asks for those, for that run only, and backing out runs nothing; on a step with more than one host, the question says that the value goes to all of them, and a list from the server is read on the first of them. With nobody to ask (a schedule, a link, another app), the step stops, naming the variable, and the workflow stops there: “The snippet “Clean up” has no value for DIR, so nothing ran. Set one on the step, or give it a default in the snippet.”

Any other ${NAME} with no value goes to the shell as written, whoever starts the run, so tar czf ${HOME}/backup.tgz /etc uses each host’s own $HOME.

A snippet or command step can run on more than one host. Runs on opens What this step runs on:

  • Hosts: the hosts you tick.
  • A group: every host in the group when it runs that can run a command.
  • All hosts: every host you have when it runs that can run a command, ones you add later too.

A workflow runs its commands over SSH, so SSH, Mosh and Eternal Terminal hosts can run them. A serial host runs one where a step names it: on its console server, over SSH, as far as that server takes a command, and never on the device on its serial line. A group and All hosts leave a serial host out. A host that is SFTP only, Telnet or this device’s own shell cannot run one, and cannot be ticked. A step saved with one before says why on that host’s row, and nothing signs in to it.

It is one step, with a result for each host. Set to stop when it fails (the default), it runs on one host at a time and stops at the first that fails; the hosts after it are skipped. With Continue on error on, it runs on a few hosts at a time, and on all of them. In a Notify step after it, {{output}} holds what each host printed, under its name.

Waits for the number of seconds you set, then goes on. It always succeeds.

Sends you a notice with the message you type. {{output}} in the message is replaced by what the last command or snippet step printed. With no message, the notice is that output itself. A message longer than 500 characters is cut short. While recording mode is on, that output is masked in the notice, as it is in Run output.

The notice is one of the app’s notices: in the bell, and on a computer also as a card in the corner of the window. On a phone, it is also a system notification, and on a computer with Also show as system notifications on, while ZestSSH is not in front. A Notify step always succeeds and needs no host.

A command or snippet step stops when its time runs out (30 seconds unless you change it). The time covers signing in to the host as well as the command.

A step fails when its command ends with another exit code, its time runs out, or ZestSSH cannot sign in to the host.

Choice What happens
Abort (the default) The workflow stops. The steps after it are marked as skipped.
Continue The workflow goes on with the next step.
Go to (phone only) The workflow goes on at the step you pick in Go to step. If that step no longer exists, the workflow stops.

On a computer, Continue on error under a step’s Advanced is the same as Continue; off, it is Abort. A computer’s editor has no Go to. A step whose snippet is gone always stops the workflow (see Snippet).

A Go to that points back to an earlier step repeats those steps while the step fails, up to 20 runs of a step. Then the workflow stops with an error that says so. A step on many hosts that goes to itself runs again only on the hosts that failed.

The workflow counts as a success only when no step aborted it and every step that ran came to a success, on every host, the last time it ran. When it succeeds and When it fails (Notify on success and Notify on failure on a phone) send a notice with how many steps succeeded, failed or were skipped, and where a step ran on many hosts, how many hosts failed.

  • On a computer: open the workflow and click Run at the top of the editor. It runs what is in the editor, saved or not. Run on… beside it asks which hosts to run on this once: they take the place of what the steps are set to run on (with Active first, and chips that tick the hosts the Server monitor says ask for a reboot, have updates or are over a limit). A new workflow saved during its own run keeps the run, its panel and its Cancel.

    The Run output panel opens over the bottom of the editor, at half its height, and stays that high: results load and scroll inside it, and its Cancel and close button stay where they are. Drag its top edge to resize it; the height is remembered on this device. Its rows are named by host, for example “edge-router: failed, exit 64”, the failures first, and each opens to what it printed. Copy all results copies them. Close the panel with its X (Show output at the top of the editor brings it back), or empty it with Clear.

  • On a phone: tap the play button (Run now) on the workflow. A bar shows “Running:” with the step it is on, and Cancel.

Before anything of a run you start runs, ZestSSH asks for any snippet variable that needs a value (see Snippet). Then, with Dangerous command protection on, it asks once about every risky command the run would run (each step’s command, each system’s command, each snippet’s with its values, as the very text that will run), and says on how many hosts. Then a snippet set to Confirm before running asks “Run this snippet?”, unless that question already covered its command. A value typed hidden stays hidden in these questions. Cancel there runs nothing. With nobody to ask (a schedule, a link, another app), Confirm before running is not asked.

While a team’s space is open, a workflow does not run from here: “Workflows run on your personal hosts. Open Personal to run this one.” Hosts of the personal space are what workflows run on, whatever is on screen. A run from a schedule, a link or another app is not touched: it runs a workflow of your personal space, whichever space is on screen (see Start a workflow from outside the app).

Cancel stops the workflow before its next step; the step that is running finishes first. On a step with many hosts, the hosts it has not started on are skipped. A run stopped this way counts as cancelled, not as a success or a failure, and sends no notice: its row in the list says Stopped. Opening another workflow, a new one or a template, closing the editor or deleting the workflow while one runs asks first: Stop this run? “What has not started yet will not run. A command already running on a host finishes there.” Stop the run stops it the same way, and Cancel leaves it going.

A run you start yourself asks you for what a sign-in needs, as a session does: a password, a key’s passphrase, or whether to trust a host’s key.

These need Squeezed, the automation switch on (External automation on a phone, Automations on at the top of Automation on a computer), and an automation API key. See API keys.

What starts from outside runs a workflow of your personal space, on your personal hosts, whichever space is on screen, and what you build a link or a schedule with lists those. A workflow saved in a team’s space never runs this way.

The workflow itself must be allowed to start from outside: API key or link under When it runs on a computer, or its switch on in the phone’s workflow list. A workflow set to Manually, or switched off, runs only when you run it in the app. A link, another app or a schedule that asks for it is refused, and Automation history says “Not run: this workflow is turned off. Turn it on in the workflow list to let links, other apps and schedules start it.” In a computer’s list, such a workflow has a pause mark beside its name.

zestssh://workflow?name=Deploy%20staging&key=YOUR_KEY
zestssh://workflow?id=WORKFLOW_ID&key=YOUR_KEY

The workflow is found by its id, or by its name (capital letters do not matter). Before it runs, ZestSSH asks Run this from a link?: “A link asks to run the workflow Deploy staging.” Nothing runs until you choose Run. On a computer, the Deep links section of the API keys tab lists each workflow’s link, with YOUR_KEY where your key goes, and Copy URL. On a phone, the workflow’s editor has Trigger this workflow externally, with its link ready to copy. Put your key in place of YOUR_KEY: ZestSSH shows a key only once, when you make it.

Send the action com.affluentlabs.zestssh.WORKFLOW with the extras key and workflow_name (or workflow_id). See Tasker and MacroDroid.

On a phone, More > Automation > Automation wizard builds the link and the intent for a workflow you pick.

A scheduled task can run a workflow, on Android and, from 4.0, on a computer while ZestSSH is open or in the tray (from 4.3 on the Schedules tab of Automation). See Scheduled tasks.

A workflow started by a link, an intent or a schedule runs with nobody there to answer. Each of its steps can sign in only with a key or password that has Allow unattended runs turned on (in Keys: on a computer, pick the key and choose Edit; on a phone, open the key’s editor), and it trusts no host key this device does not already trust. Otherwise the step fails and says why.

  • A workflow keeps the time it last ran.
  • Runs started by a link, an intent or a schedule are listed in the automation history: Automation > Runs on a computer, More > Automation > Automation history on a phone. The history keeps the newest 500 entries.
  • A run you start in the app (Run on a computer, Run now on a phone) is not added to that history.