Updated on 2025-08-12 GMT+08:00

Executing Custom Jobs

Scenarios

To execute a custom job, perform the operations in this section.

Precautions

  • Before executing a job, ensure that you have the resource permissions of target instances.
  • A maximum of 999 instances can be selected for a task.

Executing a Custom Job

  1. Log in to COC.
  2. In the navigation pane on the left, choose Resource O&M > Automated O&M.
  3. In the Routine O&M area, click Job Management.
  4. On the Custom Jobs tab page, locate the job to be executed and click Execute in the Operation column.
  5. Set Execution Type.

    • If you choose Single, perform 7.
    • If you choose Cross Account, perform 6.
    • Currently, BMS API call and scripts cannot be executed across accounts.
    • Currently, jobs that contain review steps cannot be executed across accounts.
    • To use this function, you need to add the account to the organization, configure the agency permissions, and enter the agency name in advance. For details, see Cross-Account Management.

  6. Set parameters in the Execution Account & Region area.

    • Execution Rule: Ensure that there is one execution rule. A maximum of 20 execution rules are supported.
      • Account: tenant account name, which can be viewed on the My Credentials page.
      • Region: region where the target object is located.
      • Agency: name of the agency in IAM
      • Project ID: ID of the project to which the target object belongs.
    • Location concurrency: This parameter is optional. Location concurrency controls the number of sub-tickets that are being executed, which affects the maximum number of sub-tickets that fail to be executed. For example, if the number of concurrent requests is 5, the maximum number of errors is the error threshold plus 5.
    • Error threshold: This parameter is optional. When the number of failed sub-tickets is greater than the error threshold, the job stops.

  7. Set Basic Information.

    Table 1 Basic information parameters

    Parameter

    Description

    Example Value

    Version

    Select the version of the job from the drop-down list. The version number is automatically incremented each time you save the modification.

    V1

    IAM Agency

    (Optional) Scope of permissions that can be used on COC to execute jobs.

    ServiceAgencyForCOC

    Execution Description

    (Optional) Description of the job to be executed.

    -

    Tag

    (Optional) Click Add Tag and enter a tag key and value.

    • When you enter a tag key and value, the system automatically displays all predefined tags associated with the current user.
    • A tag key can contain up to 128 characters. It cannot start with _sys_ or a space, and cannot end with a space. Only letters, digits, spaces, and the following special characters are allowed: _.:=+-@
    • A tag value can contain up to 255 characters. It cannot start or end with a space. Only letters, digits, spaces, and the following special characters are allowed: _ . : / = + - @

    -

  8. Set the execution content.

    • Region: Select the region where the target instance is located.
    • Target Instance Mode: Select the execution mode of job step and target instances.
      • Consistent for all steps: All tasks are executed on the selected instance using the same batch policy.
      • Unique for each step: Tasks in one step are executed on the selected instance. Each step uses a batch policy.
      • Unique for each task: Set the target instance and batch policy for each task.
    • Job Execution Procedure: Customize job details.
      • Click the job name. The Modifying Parameters drawer is displayed on the right.
      • Set Input, Output, and Troubleshooting.
    • Target Instance: Click Add and set Select Instance.
      Table 2 Instance parameters

      Parameter

      Description

      Example Value

      Selection Method

      Select an instance selection method.

      • Manual Selection: Manually select an instance based on Enterprise Project, View Type, Resource Type, Region, and Target Instance.

      Manual Selection

      Enterprise Project

      Select an enterprise project from the drop-down list. You can choose All.

      All

      View Type

      Select a view type.

      • CloudCMDB resources: Select an instance from the resource list.
      • CloudCMDB application groups: Select an instance from the application group list.

      CloudCMDB resources

      Resource Type

      The value can be ECS or BMS.

      ECS

      Region

      The default parameter cannot be modified and is determined by Region in Execution Content.

      CN-Hong Kong

      Target Instance

      Set filter criteria in the filter box and select the filtered instances.

      NOTE:

      Instances cannot be filtered by enterprise project-level IAM permissions.

      -

    • Batch Policy: Select Automatic, Manual, or No Batch.
      • Automatic: The selected instances to be executed are automatically divided into multiple batches based on the preset rule.
      • Manual: You can manually create multiple batches and add instances to each batch as required.
      • No Batch: All instances will be executed in the same batch.

  9. Click OK. On the displayed page, click OK.

    Change control can be enabled for custom jobs. For details about how to enable and use the change control function, see section "Change Control."

  10. Perform the following operations to check whether a service ticket execution is complete.

    • For the service tickets that are being executed:
      • If you want to pause the next batch when the current batch is executed, click Pause in the upper right corner.
      • If you want to continue the paused batch, click Continue in the upper right corner.
      • If you want to stop the service ticket that is about to be executed or is abnormal, click Forcibly End.
    • For the service tickets that are executed:
      • If some or all instance tasks in the service tickets are executed abnormally:
        1. Click the Abnormal tab in the Execution Information area. Locate an abnormal batch and click Retry in the Operation column.
        2. Click the Abnormal tab in the Execution Information area. Locate an abnormal batch and click Cancel in the Operation column.
      • If all instance tasks in the service tickets are executed successfully, no more operation is needed.