# Run automations for the tenant

> Switch on the cron jobs that run automations, give people the permission for tenant automations, choose who an automation runs as, and know every limit that keeps automations from running wild.

Most of the setup is done once: two cron jobs, and the permission for the people who look after the tenant's automations. After that, the limits on this page decide when nexxus stops an automation instead of letting it run.

## Switch on the cron jobs

Automations run in the background, driven by cron jobs. nexxus creates them switched off the first time it starts, so a new installation can build and test automations, but none of them runs by itself.

<Steps>

1. Open <MenuPath to="Settings > Operations > Maintenance > Cron Jobs" />.

2. Set `AUTOMATION_EVENTS` and `AUTOMATIONS` to <Ui>Active</Ui>.

3. If people use the delivery <Ui>Bell and digest</Ui>, set `NOTIFICATION_DIGEST` to <Ui>Active</Ui> as well.

</Steps>

<Screenshot src={shot_cron_jobs} url="/cronJob" alt="The page Cron Jobs with the jobs AUTOMATIONS and AUTOMATION_EVENTS, both active" caption="Both jobs active. The comments next to them come from the server and are in German." />

| Job | Runs | Does |
|---|---|---|
| `AUTOMATION_EVENTS` | every 2 seconds | starts the automations with <Ui>A record is created</Ui> and <Ui>A record is changed</Ui> |
| `AUTOMATIONS` | every 60 seconds | runs <Ui>On a schedule</Ui> at the minute, checks <Ui>A condition holds</Ui> every 5 minutes, and once an hour clears out old history |
| `NOTIFICATION_DIGEST` | during working hours | mails the notifications of <Ui>Bell and digest</Ui> that are still unread after four working hours, at most once a day |

**The jobs run for the whole installation**, for every tenant at once, so only a superadmin can switch them. If the page is missing from your menu, ask the person who runs your nexxus installation.

As long as a job is off, the editor says so as soon as you pick a trigger that depends on it, for example <Ui>Record triggers do not run yet: a superadmin has to switch on the cron job "AUTOMATION_EVENTS" (Settings › Operations › Maintenance › Cron Jobs).</Ui>

**Nothing is lost while `AUTOMATION_EVENTS` is off.** nexxus notes every change to a record that a switched-on automation listens to, and the job works through those changes once it runs. `AUTOMATIONS` does not catch up in the same way: a condition takes stock at its first check, and a schedule runs from the next point in time on.

## Who may do what

| | Your own automations | Tenant automations |
|---|---|---|
| Where | <MenuPath to="My profile > Automations" /> | <MenuPath to="Settings > Operations > Automations" /> |
| Who creates and changes them | everyone | people with the permission `automation.manage` |
| Who sees them | only the person they belong to, not even administrators | everyone with `automation.manage` |
| Runs as | the person they belong to | the person under <Ui>Runs as</Ui> |
| Steps | <Ui>Notify</Ui> (that person only), <Ui>Run an action</Ui>, <Ui>If / else</Ui> | all four, including <Ui>Send mail</Ui> |
| At most | 50 per person | 200 per tenant |

Administrators have `automation.manage` anyway. For anyone else, add it to one of their roles under <MenuPath to="Settings > Users & access > Access Roles" />: the role editor finds it by its key, under the module <Ui>Automations</Ui> with the action <Ui>Manage</Ui>. See [Roles and permissions](/setup/roles/). Without it, saving a tenant automation fails with <Ui>Mandantenweite Automationen braucht das Recht „Automationen verwalten“.</Ui> (tenant automations need the permission to manage automations).

Personal automations need no permission. What they can do is limited by the rights of their owner anyway.

## Runs as

Every automation acts as one person. It reads the records that person may read, and its actions run with that person's rights. A record outside those rights never matches a condition, and an action the person may not run fails.

- A tenant automation runs as the person who created it. Under <Ui>Runs as</Ui>, someone with `automation.manage` can hand it to another person of the tenant. That person must have accepted the invitation.
- A good choice is the person responsible for the subject, the information security officer for incidents for example. Then the automation acts with the rights that person has anyway.
- Choosing another person ends a pause, and the automation takes stock afresh: what matches at that moment does not trigger. It still has to be switched on and saved to run again.

**When the person is deactivated or deleted**, the automation pauses at its next run. For a tenant automation, everyone with `automation.manage` is told in the bell. Pick another person under <Ui>Runs as</Ui>, switch the automation on and save. Until then saving fails with <Ui>Die Person, der die Automation gehört, gibt es nicht mehr oder sie ist deaktiviert.</Ui> (the person it belongs to is gone or deactivated). A personal automation of a person who left pauses too; nobody else sees it, so nobody is told.

## Limits

| Limit | Value | When it is reached |
|---|---|---|
| Runs of one automation per hour | 60, adjustable per automation under <Ui>Maximum runs per hour</Ui> up to 600 | the automation pauses |
| Records in one run whose steps change data or send mail | 50 | the run is skipped and the automation pauses |
| Failed runs in a row | 5 | the automation pauses |
| Automations triggering each other in a row | 3 | the fourth is skipped |
| Records a condition may match, in the mode <Ui>every record that starts to match</Ui> | 1,000 | the check stops with an error |
| Records a schedule handles in one run | 1,000 | |
| Steps per automation, including those in <Ui>If / else</Ui> | 20 | the editor refuses more |
| Levels of <Ui>If / else</Ui> inside each other | 3 | the editor refuses more |
| People in one <Ui>Notify</Ui> step | 50 | |
| Addresses in one <Ui>Send mail</Ui> step | 20 | |
| <Ui>Repeat every … days</Ui> | 30 | |
| Shortest <Ui>Interval</Ui> of a schedule | 15 minutes | |
| History | 90 days, at most 500 runs per automation | older runs are deleted |
| Own automations per person | 50 | creating more fails |
| Tenant automations per tenant | 200 | creating more fails |

Why the limits are there, and what to do when an automation pauses, is in [Test run and history](/automations/test-and-history/#when-an-automation-pauses).

## Switch off, duplicate, delete

The switch on each card in the list turns an automation on or off without opening it. A switched-off automation rests. When it is switched on again, it takes stock afresh: a trigger <Ui>A condition holds</Ui> starts from what matches at that moment and does not report it.

At the top of the editor, next to the name:

- <Ui>Duplicate</Ui> opens a new automation with the same settings, named <Ui>… (copy)</Ui>. It starts switched off, so two automations do not do the same thing, and it runs as the person who saves it. Nothing is created until you click <Ui>Create automation</Ui>.
- <Ui>Delete</Ui> asks first: <Ui>The automation "…" will be deleted and stops running. Its history goes with it.</Ui>

## Notification rules became automations

The update that brought automations moved every notification rule into a personal automation of its owner, with the trigger <Ui>A condition holds</Ui> and one step <Ui>Notify</Ui> <Ui>me</Ui>. The automation keeps the rule's name, source, condition, delivery and whether it was switched on.

- It also keeps what the rule already knew, so nobody gets a notification twice and nobody misses one.
- The rule itself is switched off and no longer shown.
- If the cron job `NOTIFICATION_RULES` was on, the update switches on `AUTOMATIONS` in its place, on the same server. Otherwise switch on the jobs as described [above](#switch-on-the-cron-jobs).

Nobody has to do anything else. The people who had rules find them under <MenuPath to="My profile > Automations" />.

## Next steps

<CardGrid>
  <LinkCard title="Test run and history" href="/automations/test-and-history/" description="Read what every run did, and why an automation paused." />
  <LinkCard title="Extend automations" href="/automations/extend/" description="What package modules bring along, and the interfaces for new triggers and steps." />
</CardGrid>