# Configuring the Drupal cron routine

> Set up a cron job so Drupal runs its maintenance tasks, such as search indexing and cleanup, automatically on a regular schedule.

Source: https://helpcenter.ruachost.com/apps/drupal/configuring-the-drupal-cron-routine/

Drupal includes a **cron routine** that performs essential maintenance tasks automatically. On **ruachost.com**, you can configure cron to run at regular intervals to keep your site healthy and optimized.

## Why Use Cron in Drupal?

- Indexes site content for searches.
- Checks for system and module updates.
- Cleans up logs and temporary files.
- Ensures scheduled tasks run reliably.

## Steps to Configure Cron

### For Drupal 6

1. Log in to your **cPanel** account.
2. In the **Advanced** section, click **Cron Jobs**.
3. Under **Add a New Cron Job**, select **Once Per Day** from the common settings.
4. In the **Command** box, enter:

   ```bash
   cd ${HOME}/public_html && php ${HOME}/public_html/cron.php >/dev/null 2>&1
   ```

   *(Adjust the path if Drupal is installed in a subdirectory.)*
5. Click **Add New Cron Job**. ✅ Your account will now automatically run Drupal’s cron routine daily.

### For Drupal 7

1. Log in to your Drupal site as an administrator.
2. Go to **Reports → Status report**.
3. Copy the **Cron maintenance tasks URL** (includes a unique cron key).
4. Go to **Configuration → System → Cron**.
5. Set **Run cron every** to **Never** and save. *(This disables Drupal’s built‑in cron emulation.)*
6. Log in to **cPanel**.
7. In **Advanced → Cron Jobs**, select **Once Per Day**.
8. In the **Command** box, enter:

   ```bash
   curl -s https://example.com/cron.php?cron_key=YOUR_UNIQUE_KEY
   ```

   *(Replace with the URL copied in step 3.)*
9. Click **Add New Cron Job**. ✅ Your account will now run Drupal’s cron routine daily.

### For Drupal 8 and 9

- Cron can be configured directly in the **Drupal admin interface** under **Configuration → System → Cron**.
- Alternatively, you can set up a **cPanel cron job** to trigger the cron URL at regular intervals for more reliability.

## Important Notes

- For busy sites, consider running cron more frequently (e.g., every 6 hours).
- Always back up your site before making configuration changes.
- Cron jobs are essential for keeping Drupal secure and optimized.
