全部产品
Search
文档中心

CloudOps Orchestration Service:ACS-ECS-ScheduleToCleanUpDisks

更新时间:Dec 21, 2025

Nama Template

ACS-ECS-ScheduleToCleanUpDisks: Membersihkan disk

Eksekusi Sekarang

Deskripsi Template

Template ini menjadwalkan tugas pembersihan disk dan berguna untuk skenario yang memerlukan manajemen serta pembersihan ruang disk secara berkala pada instans Elastic Compute Service (ECS), seperti pembersihan otomatis file log dan penghapusan file sementara. Saat menggunakan template ini, Anda harus menentukan pemicu pengatur waktu (timerTrigger), ID wilayah (regionId), instans target (targets), dan aturan pembersihan (cleanUpInfos). Setelah dieksekusi, template ini mengembalikan output dari perintah pembersihan yang dapat digunakan untuk memverifikasi status operasi pembersihan disk.

Jenis Template

Otomatis

Pemilik

Alibaba Cloud

Parameter masukan

Parameter

Deskripsi

Tipe

Diperlukan

Nilai Default

Batasan

timerTrigger

Jenis tugas terjadwal.

Json

Ya

targets

Instans tujuan

Json

Ya

cleanUpInfos

Aturan untuk membersihkan data di disk.

String

Ya

Ekspresi reguler validasi string: ^["$`'\s]+$


regionId

ID wilayah.

String

Tidak

{{ ACS::RegionId }}

rateControl

Konkurensi eksekusi task

Json

Tidak

{'Mode': 'Concurrency', 'MaxErrors': 0, 'Concurrency': 10}

OOSAssumeRole

Resource Access Management (RAM) role yang diasumsikan oleh CloudOps Orchestration Service (OOS).

String

Tidak

OOSServiceRole

Parameter Output

Parameter

Deskripsi

Tipe

commandOutputs

List

Kebijakan Izin yang Diperlukan untuk Menjalankan Template

{
    "Version": "1",
    "Statement": [
        {
            "Action": [
                "ecs:DescribeInstances",
                "ecs:DescribeInvocationResults",
                "ecs:DescribeInvocations",
                "ecs:RunCommand"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Action": [
                "oos:GetApplicationGroup"
            ],
            "Resource": "*",
            "Effect": "Allow"
        }
    ]
}

Detail

Untuk informasi lebih lanjut, lihat ACS-ECS-ScheduleToCleanUpDisks.yml di GitHub.

Konten Template

FormatVersion: OOS-2019-06-01
Description:
  en: 'Schedules disk cleanup tasks. This template is useful for scenarios that require periodic management and cleanup of disk space on ECS instances, such as automatic log file cleanup and temporary file deletion. During configuration, provide the following required parameters: a timer trigger (timerTrigger) to define when the cleanup task runs, a region ID (regionId) to specify the region of the target ECS instances, target instances (targets) to define the specific ECS instances to operate on, and cleanup rules (cleanUpInfos) to specify the disk cleanup rules. After execution, the template returns a list of output from the cleanup command. This lets you verify the status of the disk cleanup operations.'
  zh-cn: Schedules disk cleanup tasks. This template is useful for scenarios that require periodic management and cleanup of disk space on ECS instances, such as automatic log file cleanup and temporary file deletion. During configuration, provide the following required parameters: a timer trigger (timerTrigger) to define when the cleanup task runs, a region ID (regionId) to specify the region of the target ECS instances, target instances (targets) to define the specific ECS instances to operate on, and cleanup rules (cleanUpInfos) to specify the disk cleanup rules. After execution, the template returns a list of output from the cleanup command. This lets you verify the status of the disk cleanup operations.
  name-en: Clean up disks
  name-zh-cn: Clean up disks
  categories:
    - time_trigger
    - application_manage
    - computenest
Parameters:
  timerTrigger:
    Type: Json
    Label:
      en: Timer trigger
      zh-cn: Timer trigger
    AssociationProperty: ALIYUN::OOS::Component::TimerTrigger
    AssociationPropertyMetadata:
      MinuteInterval: 30
  regionId:
    Type: String
    Label:
      en: Region ID
      zh-cn: Region ID
    AssociationProperty: RegionId
    Default: '{{ ACS::RegionId }}'
  targets:
    Type: Json
    Label:
      en: Target instance
      zh-cn: Target instance
    AssociationProperty: Targets
    AssociationPropertyMetadata:
      ResourceType: 'ALIYUN::ECS::Instance'
      RegionId: regionId
      Status: Running
  cleanUpInfos:
    Description:
      en: 'Format: 3d|/root/log/|*.log,3h|/root/log/|*.access,30m|C:\Users\Administrator\log\|*.log.'
      zh-cn: 'Format: 3d|/root/log/|*.log,3h|/root/log/|*.access,30m|C:\Users\Administrator\log\|*.log'
    Label:
      en: Cleanup rule
      zh-cn: Cleanup rule
    Type: String
    AssociationProperty: ALIYUN::OOS::Component::CleanUpInfo
    AllowedPattern: "^[^\"$`'\s]+$"
  rateControl:
    Label:
      en: Rate control
      zh-cn: Task execution concurrency rate
    Type: Json
    AssociationProperty: RateControl
    Default:
      Mode: Concurrency
      MaxErrors: 0
      Concurrency: 10
  OOSAssumeRole:
    Label:
      en: OOSAssumeRole
      zh-cn: RAM role assumed by OOS
    Type: String
    Default: OOSServiceRole
RamRole: '{{ OOSAssumeRole }}'
Tasks:
  - Name: timerTrigger
    Action: 'ACS::TimerTrigger'
    Description:
      en: Triggers a task as scheduled by specifying a type and expression.
      zh-cn: Triggers the task based on the specified trigger type and expression.
    Properties:
      Type:
        'Fn::Select':
          - type
          - '{{timerTrigger}}'
      Expression:
        'Fn::Select':
          - expression
          - '{{timerTrigger}}'
      StartDate:
        'Fn::Select':
          - startDate
          - '{{ timerTrigger }}'
      EndDate:
        'Fn::Select':
          - endDate
          - '{{ timerTrigger }}'
      TimeZone:
        'Fn::Select':
          - timeZone
          - '{{ timerTrigger }}'
  - Name: getInstance
    Description:
      en: Views the ECS instances.
      zh-cn: Gets the ECS instances.
    Action: 'ACS::SelectTargets'
    Properties:
      ResourceType: 'ALIYUN::ECS::Instance'
      RegionId: '{{ regionId }}'
      Filters:
        - '{{ targets }}'
    Outputs:
      instanceIds:
        Type: List
        ValueSelector: 'Instances.Instance[].InstanceId'
  - Name: cleanUpDisk
    Action: 'ACS::ECS::CleanUpDisk'
    Description:
      en: Runs a Cloud Assistant command to clean up the disk.
      zh-cn: Runs a Cloud Assistant command to clean up the disk.
    Properties:
      regionId: '{{ regionId }}'
      instanceId: '{{ ACS::TaskLoopItem }}'
      cleanUpInfos: '{{ cleanUpInfos }}'
    Loop:
      RateControl: '{{ rateControl }}'
      Items: '{{ getInstance.instanceIds }}'
      Outputs:
        commandOutputs:
          AggregateType: Fn::ListJoin
          AggregateField: commandOutput
    Outputs:
      commandOutput:
        Type: String
        ValueSelector: commandOutput
Outputs:
  commandOutputs:
    Type: List
    Value: '{{ cleanUpDisk.commandOutputs }}'
Metadata:
  ALIYUN::OOS::Interface:
    ParameterGroups:
      - Parameters:
          - timerTrigger
        Label:
          default:
            zh-cn: Cleanup time
            en: Cleanup time
      - Parameters:
          - cleanUpInfos
        Label:
          default:
            zh-cn: Rule settings
            en: Rule settings
      - Parameters:
          - regionId
          - targets
        Label:
          default:
            zh-cn: Instance selection
            en: Instance selection
      - Parameters:
          - rateControl
          - OOSAssumeRole
        Label:
          default:
            zh-cn: Advanced options
            en: Advanced options