# 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="https://4179539225-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MZqboFGZzD87nn7oPsm%2Fuploads%2FIhSLSxcCevBKHhmhs4ZK%2FScreenshot%202023-06-08%20at%2014.55.02.png?alt=media&#x26;token=26650e2d-e283-4359-b00d-8dd9de704c49" 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="https://4179539225-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MZqboFGZzD87nn7oPsm%2Fuploads%2FNtOsSUKF6K3UHZaYqnVo%2FScreenshot%202023-06-08%20at%2014.56.43.png?alt=media&#x26;token=138a10d1-e86e-49f7-ac5c-a4a957344eed" 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](https://datalab-docs.datacamp.com/work/long-running-cells "mention").

### 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
}
```
