---
title: What are init scripts?
description: Learn how to use initialization (init) scripts to install packages and libraries, set system properties and environment variables, modify Apache Spark config parameters, and set other configurations on Databricks clusters.
canonical_url: https://docs.databricks.com/aws/en/init-scripts/
---

# What are init scripts?

An init script (initialization script) is a shell script that runs during startup of each cluster node before the Apache Spark driver or executor JVM starts. This article provides recommendations for init scripts and configuration information if you must use them.

> [!NOTE]
>
> This page describes init scripts on classic compute. Serverless compute does not support init scripts. To install packages or configure the Python environment on serverless compute, see [Configure the serverless environment](https://docs.databricks.com/aws/en/compute/serverless/dependencies.md).

## <a id="recommendations" />Recommendations for init scripts

Databricks recommends using built-in platform features instead of init scripts whenever possible. Widespread use of init scripts can slow migration to new Databricks Runtime versions and prevent adoption of some Databricks optimizations.

> [!IMPORTANT]
>
> If you need to migrate from init scripts on DBFS, see [Migrate init scripts from DBFS](https://docs.databricks.com/aws/en/init-scripts/index.md#migrate).

The following Databricks features address some of the common use cases for init scripts:

* Use compute policies to set system properties, environmental variables, and Spark configuration parameters. See [Compute policy reference](https://docs.databricks.com/aws/en/admin/clusters/policy-definition.md).
* Add libraries to compute policies. See [Add libraries to a policy](https://docs.databricks.com/aws/en/admin/clusters/policies.md#libraries).

If you must use init scripts:

* Manage init scripts using compute policies or cluster-scoped init scripts rather than global init scripts. See [init script types](https://docs.databricks.com/aws/en/init-scripts/index.md#init-script-types).
* Manage library installation for production and interactive environments using compute policies. Don't install libraries using init scripts. See [compute policies](https://docs.databricks.com/aws/en/admin/clusters/policies.md#libraries).
* When you use an init script to install operating system packages with a package manager such as `apt-get`, pin specific package versions (for example, `apt-get install <package>=<version>`). Pinning versions keeps cluster environments reproducible and avoids unexpected changes.
* Use standard access mode (formerly shared access mode) for all workloads. Only use the dedicated access mode (formerly single user access mode)if required functionality is not supported by standard access mode.
* Use new Databricks Runtime versions and Unity Catalog for all workloads.

The following table provides recommendations organized by Databricks Runtime version and Unity Catalog enablement.

| Environment                                                 | Recommendation                                                                                                                            |
| ----------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| Databricks Runtime 13.3 LTS and above with Unity Catalog    | Store init scripts in Unity Catalog [volumes](https://docs.databricks.com/aws/en/volumes/volume-files.md).                                |
| Databricks Runtime 11.3 LTS and above without Unity Catalog | Store init scripts as [workspace files](https://docs.databricks.com/aws/en/files/workspace-init-scripts.md). (File size limit is 500 MB.) |
| Databricks Runtime 10.4 LTS and below                       | Store init scripts using [cloud object storage](https://docs.databricks.com/aws/en/archive/storage/connect-storage-index.md).             |

## <a id="init-script-types" />What types of init scripts does Databricks support?

Databricks supports two kinds of init scripts: cluster-scoped and global, but using cluster-scoped init scripts are recommended.

* **Cluster-scoped**: run on every cluster configured with the script. This is the recommended way to run an init script. See [Cluster-scoped init scripts](https://docs.databricks.com/aws/en/init-scripts/cluster-scoped.md).
* **Global**: run on all clusters in the workspace configured with dedicated access mode or no-isolation shared access mode. These init scripts can cause unexpected issues, such as library conflicts. Only workspace admin users can create global init scripts. See [Global init scripts](https://docs.databricks.com/aws/en/init-scripts/global.md).

Whenever you change any type of init script, you must restart all clusters affected by the script.

Global init-scripts run before cluster-scoped init scripts.

> [!IMPORTANT]
>
> Legacy global and legacy cluster-named init scripts run before other init scripts. These init scripts are end-of-life, but might be present in workspaces created before February 21, 2023. See [Cluster-named init scripts (legacy)](https://docs.databricks.com/aws/en/archive/init-scripts/legacy-cluster-named.md) and [Global init scripts (legacy)](https://docs.databricks.com/aws/en/archive/init-scripts/legacy-global.md).

## <a id="compatibility" />Where can init scripts be installed?

You can store and configure init scripts from workspace files, Unity Catalog volumes, and cloud object storage, but init scripts are not supported on all cluster configurations and not all files can be referenced from init scripts. For environment recommendations for init scripts, see [Recommendations for init scripts](https://docs.databricks.com/aws/en/init-scripts/index.md#recommendations).

The following table indicates the support for init scripts based on the source location and the cluster access mode. The Databricks Runtime version listed is the minimum version required to use the combination. For information about cluster access modes, see [Access modes](https://docs.databricks.com/aws/en/compute/configure.md#access-modes).

> [!NOTE]
>
> Standard access mode requires an admin to add init scripts to an `allowlist`. See [Allowlist libraries and init scripts on compute with standard access mode (formerly shared access mode)](https://docs.databricks.com/aws/en/data-governance/unity-catalog/manage-privileges/allowlist.md).

|                     | Standard access mode | Single access mode                                                                                                                               | No-isolation shared access mode            |
| ------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------ |
| **Workspace files** | Not supported        | All supported Databricks Runtime versions.<br />On versions below 11.3 LTS, init scripts that reference other workspace files are not supported. | All supported Databricks Runtime versions. |
| **Volumes**         | 13.3 LTS and above   | 13.3 LTS and above                                                                                                                               | Not supported                              |
| **Cloud storage**   | 13.3 LTS and above   | All supported Databricks Runtime versions                                                                                                        | All supported Databricks Runtime versions  |

## <a id="migrate" />Migrate init scripts from DBFS

> [!WARNING]
>
> Init scripts on DBFS have reached end-of-life and can no longer be used. You must migrate your init scripts to a supported location before you can start compute. Store init scripts on Unity Catalog Volumes, as workspace files, or in cloud object storage.

Users that need to migrate init scripts from DBFS can use the following guides. Make sure you've identified the correct target for your configuration. See [Recommendations for init scripts](https://docs.databricks.com/aws/en/init-scripts/index.md#recommendations).

* [Migrate init scripts from DBFS to volumes](https://docs.databricks.com/aws/en/documents/aws-init-volumes.pdf)
* [Migrate init scripts from DBFS to workspace files](https://docs.databricks.com/aws/en/documents/aws-init-workspace-files.pdf)
* [Migrate init scripts from DBFS to S3](https://docs.databricks.com/aws/en/documents/aws-init-s3.pdf)
