> ## Documentation Index
> Fetch the complete documentation index at: https://wiki.latch.bio/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuring Auto Shutdown

> Configure Pods for scheduled shutdown using systemd.

This guide explains how to set up automatic shutdown for a Pod using `systemd`. `systemd` is a system and service manager for Linux that provides a reliable and flexible way to manage services and tasks, including scheduled shutdowns.

<Warning>We advise against using this feature for Pods running long-duration or overnight scripts, as it will forcibly terminate the Pod while the script is in progress.</Warning>

1. To initiate a hard shutdown, create a systemd service unit file named `/etc/systemd/system/force-shutoff.service` with the following content:

```bash theme={null}
# /etc/systemd/system/force-shutoff.service
[Unit]
Description=Forcedly shut off this pod

[Service]
Type=exec
Restart=on-failure
SyslogIdentifier=%N

ExecStart=/usr/bin/env bash -c ' \
    curl https://nucleus.latch.bio/pods/stop \
    -H "Content-Type: application/json" \
    -H "Authorization: Latch-SDK-Token $(cat /root/.latch/token)" \
    --data "{\\"pod_id\\": $(cat /root/.latch/id)}" \
  '
```

2. Next, create a systemd timer unit file named `/etc/systemd/system/force-shutoff.timer` to specify the shutdown schedule:

```bash theme={null}
# /etc/systemd/system/force-shutoff.timer
[Unit]
Description=Forcedly shut off this pod at 5pm

[Timer]
OnCalendar=*-*-* 17:00:00 America/Los_Angeles

[Install]
WantedBy=timers.target
```

3. Enable and start the timer service using the following command:

```console theme={null}
systemctl enable --now force-shutoff.timer
```

4. If you need to change the shutdown time in the future, update the time in `/etc/systemd/system/force-shutoff.timer`, and then reload all systemd configurations within the Pod by running:

```console theme={null}
systemctl daemon-reload
```

5. If you want to disable the scheduled shutdown in the future, use the following command:

```console theme={null}
systemctl disable force-shutoff.timer
```

By following these steps, you can configure your Pod to perform a scheduled hard shutdown using systemd. This ensures that your Pod shuts down automatically at the specified time, helping you manage resources efficiently.
