---
title: "Using scheduled jobs to support your application"
date: "2024-02-14T06:18:38+00:00"
summary: "Learn how to automate maintenance tasks using scheduled jobs in Cloud Platform for efficient website management and improved performance."
image:
type: "page"
url: "/acquia-cloud-platform/using-scheduled-jobs-support-your-application"
id: "e6fcf5fd-12d6-427e-9662-10b8a6428485"
---

Table of contents will be added

To help your application run more efficiently, you must conduct regular website maintenance. You can automate maintenance tasks or jobs to run at scheduled intervals using the **Scheduled Jobs** page in the Cloud Platform user interface. This functionality is sometimes referred to as a cron job. For more information about why you must run cron jobs regularly, see [Cron automated tasks overview](https://www.drupal.org/docs/administering-a-drupal-site/cron-automated-tasks/cron-automated-tasks-overview).

Note

For information about cron and scheduling tasks on Site Factory, see [Managing cron tasks using the management console](https://docs.acquia.com/site-factory/manage/preferences/tasks/factory).

Scheduled jobs are specific to the environment where they’re created. Although you can’t create a job executing a command across several environments based on the same schedule, you can create a job for each environment, with each job using the same command line and schedule.

You must use the **Scheduled Jobs** page for scheduled jobs and not the default Drupal cron. Compared to Drupal cron, using the **Scheduled Jobs** page is more reliable, and provides support for adding extensive and integrated logging for Cloud Platform applications.

Disabling Drupal’s automated cron
---------------------------------

By default, Drupal cron (also known as _poor man’s cron_) is enabled for websites. Acquia recommends you disable Drupal cron and rely on the Cloud Platform functionality for running scheduled jobs to ensure that they will run on the schedule you specify. By contrast, Drupal’s default cron functionality is only triggered by HTTP requests and can unnecessarily keep PHP processes running for a long time, potentially causing elevated resource utilization or slower site performance. Disabling Drupal cron also enables you to avoid the performance reduction on page requests. For more information, see [Automated Cron](https://www.drupal.org/docs/administering-a-drupal-site/cron-automated-tasks/automated-cron).

To disable Drupal cron:

1.  Sign in to your Drupal website as an _administrator_.
2.  Go to **Configuration** > **System** > **Cron** (`http://[site_URL]/admin/config/system/cron`).
3.  In the **Run cron every** list, click **Never**.

Note

This option is available in the [current Drupal version](https://docs.acquia.com/service-offerings/guide/software-life-cycle#supported-drupal-version) if you have already installed the [Automated Cron](https://www.drupal.org/docs/8/core/modules/automated-cron) module. If this option does not exist for your Drupal version, you are not required to perform any additional steps.

4.  Click **Save configuration**.
5.  Uninstall the [Automated Cron](https://www.drupal.org/docs/8/core/modules/automated-cron) Drupal module.

Creating scheduled jobs
-----------------------

Note

[Limitations](#cloud-cronjob-limits) apply when creating scheduled jobs.

1.  To create a scheduled job for an environment:
    
2.  [Sign in to the Cloud Platform user interface](/node/55875).
3.  Select an application and an environment.
4.  Click **Scheduled Jobs**.
5.  Click **Add Job** to add a scheduled job.
6.  In **Job name**, enter a descriptive name for the job.
7.  In the **Command** field, enter the command you want Cloud Platform to routinely run for the environment. You can enter any commands allowed from an SSH connection to the environment, as long as they meet the [limits and special considerations](#cloud-cronjob-limits) for scheduled jobs.

Note

You must test commands using SSH in your Cloud Platform environment to ensure they work before adding the commands as automated cron commands.

8.   In **Command frequency**, select how often you want to run the command from the menus
    
    *   Every X minute, where X is the number of minutes
    *   Every hour, at a number of minutes past the hour
    *   Every day, at a certain time
    *   Every week, at a certain day of the week and time of day
    *   Every month, at a certain day of the month and time of day
    *   Every year, at a certain month, day of the month, and time of day
    
    Alternatively, you can enter the cron frequency as a string. For more information, visit [Cron time string format](/acquia-cloud-platform/help/92596-cron-time-string-format "Cron time string format").
    

Note

*   All times are UTC.
*   Running cron too often can affect performance.
*   If you configure multiple Scheduled Jobs with a command frequency of every 5 minutes in Cloud Next environments, the system distributes these jobs randomly across the 5-minute interval.

9.  Click **Submit**.  
    After you create a job, Cloud Platform displays the job in the list of scheduled jobs for the environment where it was created.

Using the Cloud Platform wrapper script for Drush cron
------------------------------------------------------

For most applications on Cloud Platform, the following basic cron functionality ensures timely cron execution and essential logging of cron output:

    /usr/local/bin/cron-wrapper.sh [site].[env] http://[site_URL]                   

In this example, you will replace the above placeholders with the following information:

*   `[site]` is the name of your application on Cloud Platform.
*   `[env]` is your environment (typically one of `dev`, `test`, or `prod`).
*   `[site_URL]` is your environment’s URL (as listed on the **Cloud** > **Domains** page). If you are using Drupal multisite, your cron jobs are specific to each website in the multisite installation. Use the URL of the website in the installation you want to target.

Important

Do not append a `cron_key` to the website URL.

The preceding script logs the output of `drush cron` to a file named `drush-cron.log`. For example, the output file is stored in the following directory based on your infrastructure:

### Cloud Next

`/shared/logs/drush-cron.log`  
  
In addition to other details, the output file contains Drush path and Drush exit code. 

### Cloud Classic

`/var/log/sites/example.prod/logs/web-9876/drush-cron.log.`

### Limitations

When creating scheduled jobs, the following limitations apply:

*   Commands in scheduled jobs cannot be longer than 255 characters. If you must run a command longer than 255 characters, you must incorporate it by [running a shell script](/acquia-cloud-platform/manage-apps/cron/advanced-cron#cloud-execute-shell-script) you run as a scheduled job.
*   The `%` character is a special character in cron commands. If your command uses this special character, be sure to precede it with a backslash (`\`). For example: `your_log_file_$(date +\%F).log`.
*   Commands entered should always provide absolute paths to ensure correct execution as shown in the following examples.
*   When you use the Acquia cron wrapper, the cron job uses the PHP memory limit for your environment (by default, 128 MB). When you use Drush cron directly, it will use the command line process memory limit, which is 512 MB.
*   On Cloud Next:
    *   You can set scheduled jobs with frequencies of less than five minutes. To do so, an account entitlement is required. Contact your account manager to use this feature.
    *   Your scheduled jobs duration must not be more than three hours. If your scheduled jobs last longer than that, it terminates.
    *   You cannot terminate long-running scheduled jobs manually through SSH sessions. If you require assistance, [create a Support ticket](/service-offerings/support#contact-acquia-support).
    *   You cannot have more than 5000 processes for scheduled jobs. If you exceed the process limit, the system restarts the service. This interrupts running requests and results in 50x errors for Drupal.

Managing scheduled jobs
-----------------------

Each job you create on the Scheduled Jobs page has links to help you manage the job, which allow you to do the following:

*   **Disable**: Stops the scheduled job from running until you click **Enable**. Disabled jobs move to the **Disabled** list that follows the **Enabled** list.
*   **Edit**: Opens a window allowing you to change the attributes of the scheduled job. After you make your changes, click **Edit**.
*   **Remove**: Opens a window deleting the scheduled job when you click **Remove**. If you remove a scheduled job, you can’t recover it, and you must manually recreate it to restore the job.

Note

You cannot edit or remove administrative jobs you did not create for your environments, including automated nightly backups.

Dedicated cron infrastructure on Cloud Platform Enterprise
----------------------------------------------------------

Some Cloud Platform Enterprise subscriptions have a dedicated cron infrastructure due to the particular performance needs of their applications. To configure a scheduled job on a dedicated cron infrastructure, contact Acquia Support. Environments running on [Cloud Next](/acquia-cloud-platform) technologies have dedicated cron capacity by default.

Security considerations for scheduled tasks
-------------------------------------------

Scheduled tasks are not encrypted. Acquia recommends that scheduled tasks must not include sensitive items such as:

*   SSL certificates
*   SSH keys
*   Login credentials
*   API credentials

Related topic
-------------

*   [Debugging cron](/acquia-cloud-platform/help/93006-debugging-cron "Debugging cron")
*   [Using Drush cron on Cloud Platform environments](/acquia-cloud-platform/manage-apps/cron/drush-cron-cpe)
*   [Advanced cron and scheduled job tasks on Cloud Platform](/acquia-cloud-platform/manage-apps/cron/advanced-cron)