You can clone an existing Cloud Assistant command to create another command. You can retain all information of the original command (cloned command), or modify the name, description, type, content, execution path, or timeout period for the new command (command clone).
Procedure
Log on to the ECS console.
In the left-side navigation pane, choose .
In the top navigation bar, select the region and resource group to which the resource belongs.
Click the My Commands tab, find the command that you want to clone, and then click Clone in the Actions column.
In the Clone Command panel, configure the parameters. The following table describes the parameters.
Parameter
Description
Command Name
Enter a name for the new command.
Execution Plan
Select a plan on when to run the new command.
Immediate execution: The command is immediately run after you click Run or Run and Save.
After the next startup of the system: The command is run the next time the associated instances are started after you click Run or Run and Save.
After each system startup: The command is run each time the associated instances are started after you click Run or Run and Save.
Run on Schedule: The command is run at a specific interval, at a specific time, or on a schedule after you click Run or Run and Save. The following execution schedule options are available:
Run at Fixed Interval: Use a rate expression to specify an interval at which you want to run the command. You can specify the interval in seconds, minutes, hours, or days. This option is suitable for scenarios in which you want to execute command execution tasks at a fixed interval.
NoteWhen you specify an interval, take note of the following limits:
The specified interval can range from 60 seconds to 7 days and must be longer than the timeout period of the scheduled task.
The interval is the amount of time that elapses between two consecutive executions. The interval is irrelevant to the amount of time that is required to run the command once. For example, you set the interval to 5 minutes, and the command requires 2 minutes to run once. Each time the command is run, the system waits for 3 minutes before it reruns the command.
After you create a task, the task does not immediately run. For example, you set the interval to 5 minutes and create a task to run the command. The task runs 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 the Execution time parameter to May 17, 2022, 17:30:50 and the Time Zone parameter to (GMT+08:00) Asia/Shanghai, the command was run only once at 17:30:50 on May 17, 2022 (UTC+8).
Run on Clock-based Schedule Cron Expression: Use a cron expression to specify a schedule on which you want to run the command. Specify a schedule that is accurate to seconds, minutes, hours, 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 schedule based on the cron expression and the time zone and runs the command as scheduled. This option provides flexibility and is suitable for scenarios in which you want to execute command tasks on a schedule. For more information about cron expressions, see Cron expressions.
NoteThe minimum interval must be 10 seconds or longer and cannot be shorter than the timeout period of scheduled executions.
For example, if you set the Execution Frequency parameter to 0 0 12 ? * WED 2022 and the Time Zone parameter to (GMT+08:00) Asia/Shanghai, the system runs the command at 12:00: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 content
Enter or paste the command content.
For information about shell commands, see View the system configurations of ECS instances.
Command Description
Enter a description for the new command. We recommend that you enter identifiable information, such as the purpose of the command, to facilitate subsequent management and maintenance.
Execution Path
Specify an execution path for the new command. Default execution paths for instances that use different operating systems:
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
Specify a 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 to a value of less than 10, the system changes the value to 10 to ensure that the execution succeeds.
Tag
Configure the Tag key and Tag value parameters to specify the tags that you want to add to the new command to facilitate subsequent classification and management.
After you confirm the configured parameters, click Clone.