How a job flows#
This page is about what happens between Start and End: how a run moves from task to task, what a task hands to the next, and how a job does two things at once, repeats something, or brings paths together again.
A path and its list#
A run begins as one path. The path carries a list of items: files and folders, each with its address, name, size, date and whatever earlier tasks noted on it.
Each task on the path:
- takes the list,
- does its work on every item its filter matches (see Conditions on a task),
- hands a list to the task its line leads to.
What a task hands on depends on the task. A Find hands on what it found. A Copy hands on the same items, still at the place they were copied from; a Move hands them on at their new place. A Zip adds the zip file to the list. An Email hands on what it was given. An Exclude hands on fewer items. Each task's page says what it passes on.
Items a task's filter does not match are never lost: they pass through untouched.
A task with no items still runs once where that makes sense: a MakeDirectory makes its folder, an Email is sent, an Execute runs its command.
Success and failure#
Every task has a green dot, for success, and a red dot, for failure.
- A task that did its work: the path follows the green line.
- A task that failed: the path follows the red line, if there is one. The error is in
{task_error}for the tasks that follow, so that an Email can say what went wrong. - A task that failed and has no red line: the path goes to the task named Default Failure, if the job has one.
- A task that failed with no red line in a job without such a task: the path ends there. Nothing behind the failed task runs, and the run ends as "completed with errors".
So a job stops at the first error unless you draw what shall happen instead. To go on after an error, draw the red line to the next task. To do the same after any error anywhere, give the job one task named Default Failure, usually an Email. See When a job fails.
One line per dot#
A dot has one line. That is the rule that makes a job readable: from a dot, a run goes to one place.
To go to two places, the job says so with a task:
| To | Use | What happens |
|---|---|---|
| do several things with the same files, at once or one after the other | Branch | every dot of the Branch gets its own copy of the items |
| send some files one way and the rest another | Jump | the items for which the condition holds go to the true line, the others to the false line |
| do something for each file, or again and again | Loop | the tasks in the loop's frame run once per pass |
| bring paths together again | Wait / Joiner | waits for the branches and goes on with their merged items |
Many lines may arrive at a task. That is how two paths lead to the same Email.
Branches#
A Branch has between 2 and 20 numbered dots. Each dot can have a name and a filter, so that one branch gets the *.pdf and another the *.csv. The dots run all at once, or one after the other in the order of their numbers.
Two things to know:
- Every branch owns its list. Each dot gets a copy of the items its filter matches. What one branch does to its items, renaming or removing them, never reaches another branch.
- Variables belong to the whole job. A variable set in one branch is seen in the others. Two branches that run at once and set the same variable overwrite each other: give them different names, or run the dots one after another.
A branch ends where its line ends: at End, at a joiner, or at a task with no line out. The run ends when all its paths have ended.
Joining#
A Wait / Joiner with Join the branches ticked waits until every branch that can still reach it has arrived. Then one path goes on, with one list:
| Merge | The list after the joiner |
|---|---|
| Union | every item once. Two entries with the same address are one item. |
| Intersection | only the items every branch still has |
| Keep all | every branch's items, duplicates too |
A joiner can be given a timeout, and told what to do then: fail, or go on with the branches that have arrived. It can also be told to fail when a joined branch failed.
Without a joiner, a task that two branches both lead to runs once per branch: an Email at the end of two branches is sent twice. Put a joiner in front of it to send one.
Loops#
A Loop is a task and a frame. The tasks in the frame are the body: they run once per pass.
| Mode | A pass |
|---|---|
| For each item | one item, or a batch of so many, per pass |
| A number of times | so many passes, each with the whole list |
| While a condition is true | checked before each pass |
| Until a condition is true | checked after each pass |
The Loop has three dots: Body leads into the frame, Done is followed when the loop has finished, Failure when it failed. Inside the body, a task with no line out ends the pass, and a line that leaves the frame ends the loop.
In a pass, {loop_number} is 1, 2, 3 …, {loop_index} counts from 0, {loop_total} is the number of passes where it is known, and {loop_first} and {loop_last} are true in the first and last pass. Every loop has limits, Most passes (1000 unless you change it) and Most minutes, so that a condition that never comes true cannot run for ever.
Loops can be inside loops, and branches inside loops.
The check before a run#
Before a run starts, the server checks the job's lines. A job it cannot run as drawn is refused, with the reason:
v27 runs one line per dot: add a Branch task.
The designer shows the same findings while you draw, as Flow warnings.
Jobs from CrushFTP 11#
In CrushFTP 11 a dot could have several lines, and the tasks behind them ran at once on the same list. Such a job is not changed when the server is updated, and it is not run as it is either: the designer marks it with a warning and offers Convert to Branch, which puts a Branch task where the lines parted. Look at the job afterwards: in 11 the paths shared one list, and now each has its own.
A Jump "to the task named …" from 11 keeps working: the designer draws the true and the false line to the named tasks.
Linked jobs#
A job can call another job as if it were one task: the Link task. The other job's tasks run inside this run, on this run's items, and what they leave comes back. That is how steps that many jobs share are kept in one place.
Link after start and Link before end in a job's Setup put such a call at the very beginning and the very end of a job without drawing it: the same "log the start" and "report the end" for every job, for example. The link before the end is taken on every way to End, after a failure too.
A Link can also start the other job as a run of its own, and not wait for it. For pieces that are copied into a job rather than called, see task groups.