# Scheduled runs

DataLab notebooks can be configured to run on a daily or weekly schedule. You can configure a scheduled run by going to 'Run > Schedule run'.

<figure><img src="/files/yyAwbhCgT4QxanocLdXm" alt=""><figcaption></figcaption></figure>

You can now configure the frequency and at what point in time the notebook should run. Additionally, you can specify whether or not you want to be notified by e-mail if the run succeeded and/or failed.

<figure><img src="/files/r2OUMpkxYgyBrovaGQ1Z" alt=""><figcaption></figcaption></figure>

Email notifications are a personal setting per scheduled notebook run. This means that if you are collaborating on a notebook, you and your peer can have different settings for the e-mail notifications for the same notebook schedule.

You can only specify one schedule per notebook; it's not possible to have a notebook run multiple times per day on a schedule.

For long-running notebooks the same limitations apply as dictated in [Long-running cells](/work/long-running-cells.md).

### Scheduled run variable

The built-in `DL_SCHEDULED_RUN` environment variable can be used to figure out whether a notebook is being run as part of a scheduled run. You can use this environment variable to decide if you want to do certain things on a schedule but not when run manually or vice versa.

As an example, you may want to post a summary of the analysis in your scheduled notebook to Slack but you don't want to accidentally post anything when you're just working on improving the analysis.&#x20;

The `DL_SCHEDULED_RUN` environment variable is set to `"TRUE"` when the notebook is being run as part of a scheduled run. The environment variable is not set if the notebook is being run manually, not as part of a scheduled run:

```python
# Python
import os

if os.environ.get('DL_SCHEDULED_RUN') == 'TRUE':
  # Your side effect here
```

```r
# R
if (Sys.getenv("DL_SCHEDULED_RUN") == "TRUE") {
  # Your side effect here
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://datalab-docs.datacamp.com/work/scheduled-runs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
