What starts a job#
A job runs when something starts it. There are seven ways.
| Started by | Use it for | The run begins with |
|---|---|---|
| a schedule | work that is due at a time | an empty list |
| an event of a user | work on files the moment they arrive or leave | the files of the event |
| a watched folder | files that appear in a folder by other ways than a login | the files that appeared |
| another job | steps that several jobs share, and chains of jobs | the calling job's items |
| an alert | reacting to something the server noticed | one item with the facts of the alert |
| the API | other programs | an empty list, and the variables the call gave |
| you | testing, and work on demand | an empty list |
A job that begins with an empty list usually has a Find as its first task. A job that is given its files does not need one.
A schedule#
Every so many minutes, or at given times on given days: see Schedules. The run is marked Scheduled under Active Jobs.
An event of a user#
An event of a user, a group or a template starts a job when a user uploads, downloads, deletes, renames, logs in, and so on. In the event, choose the action Run Plugin and then either:
- the job's name from the group Job of the list: the job of the Jobs app, or
- CrushTask (User Defined): a job that is drawn inside the event and belongs to it.
See Running a job from an event. The run begins with the files of the event, and its tasks can use what is known about the user: {user_name}, {user_email}, {user_ip} and the rest. Under Active Jobs, such runs are found with User events.
Two events are special: the pre-download event, whose job can prepare or replace the file a user is about to get, and the custom event, which puts a button of the job into the web interface.
A watched folder#
Folder Monitor in the Preferences watches a folder of the server's own disk and starts a job for files that appear, or that are older than a given age. Use it for files that reach the folder without a login: from a program on the same machine, a mounted share, a scanner.
For folders on other servers there is no watching: schedule a job with a Find every few minutes.
Another job#
The Link task calls another job. Unless you say otherwise, the other job's tasks run inside the calling run and on its items; with Run as external job the other job gets a run of its own, with the items or without, and the caller waits for it or not.
Link after start and Link before end in a job's Setup put such a call at the beginning and the end of a job.
An alert#
An alert can run a job in place of sending a mail: for a disk that is nearly full, a login that failed too often, a user that was banned. The job gets the facts of the alert as variables.
The API#
POST /WebInterface/api/v1/jobs/{name}/run
answers 202 with the id of the run, and the run can then be watched with GET /job-runs/{id}. See Jobs in the API. The caller needs the right to run the job: see Who may see, change and run a job.
By hand#
Run Job and Run & Monitor Job in the job list, and Test & Run Job in the designer. Also from the admin pages: Running jobs.
Who the job runs as#
Whatever started it, a job runs with the authority that was written into it when it was last saved, not with the rights of whoever or whatever started it. A user whose upload starts a job cannot make the job do more than its tasks say, and the job can do things that user may not. See Who may see, change and run a job.
Many starts at once#
- A job may have several runs at the same time, unless Single instance only is ticked in its Setup.
- Runs that cannot start at once wait for room on an engine: the Engines section lists them with the reason. See Job engines.
- An event that fires a thousand times starts a thousand runs. For uploads in bulk, use the event's timing "after the user logs out" or "after a period of inactivity", so that one run gets all files: see the event editor.