Information for: DEVELOPERS   PARTNERS

Scheduled jobs in Acquia Cloud Site Factory

This page describes an Acquia Cloud Site Factory feature. For the Scheduled Jobs user interface for cron in Acquia Cloud, see Using scheduled jobs to support your application.

The scheduled jobs feature for Acquia Cloud Site Factory enables you to add one-time, complex data processing jobs to be executed at a single, specific time in the future. If the job must be performed multiple times, you should instead use cron jobs scheduled through the Acquia Cloud Site Factory interface.

Scheduled jobs aren’t executed through HTTP web requests. Unlike cron jobs, you can review the outcome and historical performance data for scheduled jobs in the Site Factory Management Console.

Contact your Account Manager to request access to the scheduled jobs feature.

Creating a scheduled job

You create scheduled jobs from the command line by providing your desired domain, timing, and command to perform. To create a new scheduled job, SSH in to your environment, and then issue the following command, replacing each field in brackets with your command’s information:

./sjadd TIMESTAMP DOMAIN [DRUSH_COMMAND] [DRUSH_EXECUTABLE] [DRUSH_OPTIONS]
  • TIMESTAMP: The Unix timestamp when the job should be invoked. If you provide a timestamp in the past, Acquia Cloud Site Factory adjusts the scheduled execution time to perform the job in the near future.

  • DOMAIN: The domain to execute the Drush command against.

  • [DRUSH_COMMAND] (Optional): The Drush command to invoke.

  • [DRUSH_EXECUTABLE] (Optional): The version of Drush to execute, such as drush8.

  • [DRUSH_OPTIONS] (Optional): The options, or flags, to use on the Drush command:

    Option Value Explanation
    -? --help Show help.
    -e --environment=value The hosting environment.
    -r --reason=value The reason why a scheduled job has been added.
    -s --sitegroup=value The hosting sitegroup.
    -t --max-exec-time=value The maximum execution time before the command is terminated.

For example, to run the cron_hsc Drush command on domain example1.com at 12:00 AM on January 1, 2020, you would perform the following command:

./sjadd 1577836800 example1.com cron_hsc

Important

You can’t modify or delete an individual scheduled job after you create it. However, you can delete all scheduled jobs for a domain name. If you need additional assistance, contact Acquia support.

Reviewing scheduled job history

  1. Sign in to the Site Factory Management Console using an account with the platform admin role.

  2. In the admin menu, click Administration, and then click the Scheduled jobs history link.

  3. Acquia Cloud Site Factory displays the Recent Job History, which includes an overview of the scheduled jobs performed in recent days, and an Archived Job History of historical data:

    Table displaying overview of scheduled jobs performed recently

    • Date (UTC): The day, month, and year the scheduled job was performed.
    • Total jobs executed: The total number of jobs performed on this day.
    • Total failed jobs: The total number, and percentage, of jobs that failed on this day.
    • Total delayed jobs: The total number, and percentage, of jobs that failed to begin execution within the defined acceptable latency period.
    • View jobs: A link to view a summary of all jobs performed on this day.

To display a detailed listing of scheduled jobs completed for a day, and access details about an individual job, click the View jobs link for your desired day.

Reviewing jobs performed in a single day

After identifying a calendar day of jobs you want to view, the Site Factory Management Console displays a table of all jobs performed that day:

Table displaying all scheduled jobs performed on a calendar day

  • Domain name: The domain name this job was performed for. To view a list of all recent jobs for this domain, click the domain name.
  • ID: The numeric ID for this job. To view detailed information about this job’s performance and outcome, click this link.
  • Status: An image displaying whether the scheduled job ended in success or failure.
  • Scheduled time (UTC): The time, in UTC, for when this job was scheduled.
  • Start time (UTC): The time, in UTC, for when this job began executing.
  • Latency (ms): The delay, in milliseconds, in the Site Factory Management Console. For more information, see Latency in scheduled jobs.
  • Exit code: Whether this job ended in success or failure.
  • Run time (ms): The time, in milliseconds, needed to complete this job. To obtain the time in seconds, divide this number by 1000.

Reviewing detailed information about a scheduled job

When reviewing the list of jobs performed on a calendar day, you can view detailed information about the performance and outcome of a specific job. The Acquia Cloud Site Factory displays the overview information displayed on the per-day list of scheduled jobs and the following additional detail about the job in the Property column:

Table displaying detailed information about a scheduled job's outcome

  • Command: The command executed by this scheduled job.
  • Retries: The number of times the scheduled job was retried, if any.
  • stdout: The ‘standard output’ of the command.
  • stderr: The ‘standard error’ message, containing error messages or diagnostic information.
  • Exit code: The numeric code returned by this process. 0 indicates success.

Latency in scheduled jobs

The scheduled jobs feature defines a latency threshold which determines if the job’s start time should be counted as delayed. To request an increase or decrease in the default latency threshold of 15 seconds, contact Acquia support.

Deleting scheduled jobs for a website

You cannot delete an individual scheduled job, but you can remove all scheduled jobs for a domain by SSHing into your environment and issuing the command ./sj rm [domain], replacing [domain] with the website’s domain name.

Important

Acquia Cloud Site Factory immediately removes all scheduled jobs for the domain you specify. This action cannot be undone.

Scheduled jobs and code deployments

You do not need to disable schedule jobs when performing code deployments. Scheduled jobs will always execute against your production website, regardless of whether it is currently hosted on the live or update environment.

Acquia Cloud Site Factory pauses scheduled jobs before moving websites from the live environment to the update environment, to prevent data inconsistencies. The scheduled jobs are re-enabled on the update environment, and remain enabled on the website until it is placed into maintenance mode for updating. When the website is taken out of maintenance mode, Acquia Cloud Site Factory will re-enable scheduled jobs for this website on the live environment.

Note

If the scheduled jobs back end requires an update as part of an Acquia Cloud Site Factory platform release, Acquia Cloud Site Factory will pause scheduled jobs to allow the service to update.

Scheduled jobs and website duplication tasks

When duplicating a website, as either a clean copy or a full website clone, Acquia Cloud Site Factory duplicates scheduled jobs from the original website, and updates them to reflect the domain name for the new website.

Deleting a website or domain with scheduled jobs

Scheduled jobs are tied to a domain name. If you delete the domain name associated with a scheduled job, Acquia Cloud Site Factory attaches the scheduled jobs to another domain name associated with the same website.

If, instead of deleting a domain name, you delete the entire website, all scheduled jobs associated with that website are immediately deleted.