A command clone operation creates a new version of an existing Cloud Assistant command. You can retain all the information of the original command (cloned command), or you can modify information such as the name, description, type, content, execution path, or timeout period in the new command (command clone).

Procedure

  1. Log on to the ECS console.
  2. In the left-side navigation pane, choose Maintenance & Monitoring > ECS Cloud Assistant.
  3. In the top navigation bar, select a region.
  4. On the Commands tab, find the Cloud Assistant command that you want to clone and click Clone in the Actions column.
  5. In the Clone Command panel, configure the parameters described in the following table.
    Parameter Description
    Command Name Specify a name for the new command.
    Implementation plan Select a command execution plan.
    • Immediate execution: The command is run immediately after you click Run or Execute and Save.
    • After the next startup of the system: The command is run the next time the selected instances are started after you click Run or Execute and Save.
    • After each system startup: The command is run each time the selected instances are started after you click Run or Execute and Save.
    • Run on Schedule: The command is run at a specified interval, at a specified time, or on a schedule after you click Run or Execute and Save. If you set Implementation plan to Run on Schedule, the following options are available:
      • Run at Fixed Interval: Use a rate expression to specify an interval at which to run the command. You can specify the interval in seconds, minutes, hours, or days. This option is applicable when tasks need to be executed at a fixed interval.
        Note When you set an interval, take note of the following limits:
        • The specified interval can only be anywhere from 60 seconds to 7 days and must be longer than the timeout period of the recurring task.
        • The specified interval is the amount of time elapsed between two consecutive times that the command is run on the selected instances. This interval does not relate to the amount of time required to run the command each time. For example, assume that you set the interval to 5 minutes and that it takes 2 minutes to run the command each time. Each time the command is run, the system waits 3 minutes before it runs the command again.
        • A task is not executed immediately after the task is created. For example, assume that you set the interval to 5 minutes for a task. The task begins to be executed 5 minutes after it is created.
      • Run Only Once at Specified Time: Specify a point in time and a time zone to run the command only once.

        For example, if you set Execution Time to 2022-05-17 17:30:50 and Time Zone to (GMT+8:00) Asia/Shanghai, the command was run only once at 17:30:50 on May 17, 2022 (UTC+8).

      • Run on Clock-based Schedule: Use a cron expression to specify a schedule on which to run the command. Set Execution Frequency to a cron expression that defines a schedule accurate to the second, minute, hour, day of the month, month, day of the week, or year, and select a time zone from the Time Zone drop-down list. The system calculates the execution times of the command based on this cron expression and time zone and runs the command as scheduled. This option provides flexibility and is applicable when tasks need to executed on a regular basis. For more information about cron expressions, see Cron expression.
        Note The minimum interval must be 10 seconds or more and cannot be shorter than the timeout period of the recurring task.

        For example, if you set Execution Frequency to 0 0 12 ? * WED 2022 and set Time Zone to (GMT+8:00) Asia/Shanghai, the system runs the command at 12:00 every Wednesday in 2022 (UTC+8).

    Command Type Select a command type.
    • For Linux instances, select Shell, Python, or Perl.
    • For Windows instances, select Bat or PowerShell.
    Command Enter or paste the command content.

    For more information about shell commands, see View instance configurations.

    Command Description Specify a description for the new command. We recommend that you set a description with information such as the command purpose that makes the command easy to identify, manage, and maintain.
    Execution Path Specify an execution path for the new command. Different default execution paths are provided based on the operating system of instances on which the command is run.
    • For Linux instances, the default execution path is the /home directory of the root user.
    • For Windows instances, the default execution path is C:\Windows\system32.
    Timeout Period Set the timeout period for the new command to run on instances. If a task that runs a command times out, Cloud Assistant forcefully stops the task process.

    Unit: seconds. Default value: 60. Minimum value: 10. If you set Timeout Period to a value of less than 10, the system changes the value to 10 to ensure that the execution succeeds.

  6. After you confirm the configured parameters, click Clone.