All Products
Search
Document Center

Elastic Compute Service:Clean up disk files periodically with OOS

Last Updated:May 15, 2026

Schedule automatic disk file cleanup across multiple ECS instances with CloudOps Orchestration Service (OOS) to prevent disk space exhaustion.

Note

CloudOps Orchestration Service (OOS) is a free cloud-based O&M automation platform that standardizes tasks as code. See What is CloudOps Orchestration Service?.

Prerequisites

Procedure

Important

Back up data on the ECS instances before running a cleanup task to prevent data loss. For example, create snapshots for the disks.

  1. Log on to the CloudOps Orchestration Service (OOS) console.

  2. In the left-side navigation pane, choose Automated Task > Common O&M Tasks > Disks were cleaned up., and click Create.

    image

  3. In the Set rules area, configure File retention period, Unit, Cleanup path, and Cleanup file.

    Example: *.log files in /home/admin/logs/ are deleted after 7 days.

    image

    Click the image icon next to a rule to add more cleanup paths and files.

    Important

    Verify that the cleanup paths and files are correct to avoid accidental deletion of important data.

  4. Click Cleanup time to configure the execution schedule and task permissions.

    • Scheduled type: Select Periodic execution and set the Recurrence Frequency.

      You can set the recurrence using preset periods or a cron expression. The following example uses a cron expression.

      Example: run the cleanup task at 23:00:00 on the fifth day of each month, ending at 23:00:00 on August 31, 2026 (China/Shanghai time):

      image

    • Permissions: Select Specify RAM Role and Use Permissions Granted to This Role (default), and select the default OOS role OOSServiceRole. See Set a RAM role for OOS and grant permissions.

  5. Click Select Instances and select the target instances.

    image

  6. Click Advanced (Optional). Set Rate Control to Concurrency-based Control, and configure Concurrency and Error Threshold.

    • Rate Control:

      • Concurrency-based Control: Maintains the specified concurrency rate until the task completes. Use this to control resource consumption.

      • Batch-based Control: Runs the task in batches; the next batch starts after the previous one completes. Use this to control execution pace or ensure processing order.

    • Concurrency: The number or percentage of instances that run the task concurrently. In this example, the value is 1 (one instance at a time).

    • Error Threshold: The maximum number of allowed errors before the task stops. Accepts a number or percentage. Default value: 0 (stops on the first error). Set to 100% to ignore all errors.

    image

  7. Keep the defaults for Execution settings (Optional) and click Create.

  8. In the Parameter Confirmation dialog box, verify the settings and click OK.

  9. View the execution details.

    In the task list, click Details in the Actions column.