首页 RunCommand

RunCommand

更新时间: 2026-07-22 16:35:54

Runs a Shell script on one or more Lingjun nodes.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

eflo:RunCommand

update

Node

acs:eflo:{#regionId}:{#accountId}:node/{#NodeId}

Command

acs:ecs:{#regionId}:{#accountId}:command/{#CommandId}

None None

Request parameters

Parameter

Type

Required

Description

Example

Name

string

No

The command name.

testName

Description

string

No

The command description.

testDescription

CommandContent

string

No

The command content. Note the following items:

  • When EnableParameter is set to true, you can use custom parameters in the command.

  • Define custom parameters in the {{}} format. Within {{}}, the spaces and line feeds before and after the parameter names are ignored.

  • You can specify up to 20 custom parameters.

  • A custom parameter name can contain only letters, digits, underscores (_), and hyphens (-). The name is not case-sensitive.

  • Each custom parameter name is up to 64 bytes in length.

ZWNobyAxMjM=

Timeout

integer

No

The timeout period for the command. Unit: seconds. A timeout error occurs when the command cannot run because the process slows down or a specific module or Cloud Assistant Agent does not exist. When the timeout period ends, the command process is forcefully terminated. Default value: 60.

3600

WorkingDir

string

No

The working directory of the command. Default path:

Linux instances: By default, the path is in the /home directory of the root user.

/home/user

EnableParameter

boolean

No

Whether to use custom parameters in the command.

Default value: false.

false

ContentEncoding

string

No

The encoding mode of the command content. Valid values:

  • PlainText

  • Base64

Default value: PlainText. If an invalid value is specified, PlainText is used by default.

Base64

Username

string

No

The username to run the command. The name can be up to 255 characters in length. For Linux instances, the root user is used by default.

root

NodeIdList

array

No

The node list.

string

No

The node ID.

"i-bp185dy2o3o6neg****"

RepeatMode

string

No

The mode to run the command. Valid values:

  • Once: runs the command immediately.

  • Period: runs the command based on a schedule. When set to Period, Frequency is required.

  • NextRebootOnly: runs the command the next time the instance is started.

  • EveryReboot: runs the command every time the instance is started.

Default value:

  • If you do not specify Frequency, the default value is Once.

  • If you specify Frequency, RepeatMode is set to Period regardless of whether a value is already specified.

Once

ClientToken

string

No

The client token that ensures idempotency of the request. Generate a unique token from your client. The token can contain only ASCII characters and cannot exceed 64 characters in length. For more information, see "How to ensure idempotence".

123e4567-e89b-12d3-a456-426655440000

Frequency

string

No

The schedule to run the command. Supported schedule types: at a fixed interval based on a rate expression, run only once at a specific time, or run at specific times based on a cron expression.

  • To run the command at a fixed interval, use a rate expression to specify the interval. The interval can be in seconds, minutes, hours, or days. This option is suitable for scenarios in which tasks need to be executed at a fixed interval. Format: rate(<Execution interval value> <Execution interval unit>). For example, rate(5m) means to run the command every 5 minutes. When you specify an interval, take note of the following limits:

    • The interval can be anywhere from 60 seconds to 7 days, but must be longer than the timeout period of the scheduled task.

    • The interval is the time between two consecutive executions, irrelevant of the time required to run the command. For example, assume that you set the interval to 5 minutes and that it takes 2 minutes to run the command each time. The system waits 3 minutes before running the command again.

    • The command is not immediately executed after the task is created. For example, assume that you set the interval to 5 minutes. The task begins to be executed 5 minutes after it is created.

  • To run a command only once at a specific point in time, specify a point in time and a time zone. Format: at(yyyy-MM-dd HH:mm:ss <Time zone>). If you do not specify a time zone, the Coordinated Universal Time (UTC) time zone is used by default. The time zone name supports the following formats: Full name, such as Asia/Shanghai and America/Los_Angeles. The time offset from GMT. Examples: GMT+8:00 (UTC+8) and GMT-7:00 (UTC-7). If you use the GMT format, you cannot add leading zeros to the hour value. The time zone abbreviation. Only UTC is supported. For example, to configure a command to run only once at 13:15:30 on June 6, 2022 (Shanghai time), set the time to at(2022-06-06 13:15:30 Asia/Shanghai). To configure a command to run only once at 13:15:30 on June 6, 2022 (UTC-7), set the time to at(2022-06-06 13:15:30 GMT-7:00).

  • To run a command at designated points in time, use a cron expression to define the schedule. Format: <Cron expression> <Time zone>. Example: <Seconds> <Minutes> <Hours> <Day of the month> <Month> <Day of the week> <Year (optional)> <Time zone>. The system calculates the execution times of the command based on the specified cron expression and time zone and runs the command as scheduled. If you do not specify a time zone, the system time zone of the instance is used by default. For more information, see Cron expressions. The time zone name supports the following formats:

    • Full name, such as Asia/Shanghai and America/Los_Angeles.

    • The time offset from GMT. Examples: GMT+8:00 (UTC+8) and GMT-7:00 (UTC-7). If you use the GMT format, you cannot add leading zeros to the hour value.

    • The time zone abbreviation. Only UTC is supported.

    For example, if you specify a command to run at 10:15:00 every day in 2022 in China/Shanghai time, set the time to 0 15 10 ? * * 2022 Asia/Shanghai. To configure a command to run every half an hour from 10:00:00 to 11:30:00 every day in 2022 (UTC+8), set the schedule to 0 0/30 10-11 * * ? 2022 GMT+8:00. To configure a command to run every 5 minutes from 14:00:00 to 14:55:00 every October every two years from 2022 in UTC, set the schedule to 0 0/5 14 * 10 ? 2022/2 UTC.

0 */20 * * * ?

Parameters

object

No

The key-value pairs of custom parameters to pass in when the command includes custom parameters. For example, if the command content is echo {{name}}, you can use Parameters to pass in the {"name":"Jack"} key-value pair. The name key of the custom parameter is automatically replaced by the paired Jack value to generate a new command. As a result, the echo Jack command is run.

You can specify 0 to 10 custom parameters. Note the following items:

  • The key of a custom parameter can be up to 64 characters in length, and cannot be an empty string.

  • The value of a custom parameter can be an empty string.

  • If you want to retain a command, make sure that the command after Base64 encoding, including custom parameters and original command content, does not exceed 18 KB in size. If you do not want to retain the command, make sure that the command after Base64 encoding does not exceed 24 KB in size. You can set KeepCommand to specify whether to retain the command.

  • The specified custom parameter names must be included in the custom parameter names that you specify when you create the command. You can use empty strings to represent the parameters that are not passed in.

This parameter is empty by default, which means the custom parameter feature is disabled.

{"name":"Jack", "accessKey":"LTAIdyvdIqaRY****"}

CommandId

string

No

The ID of the command.

c-e996287206324975b5fbe1d***

TerminationMode

string

No

How the command task is stopped when a command execution is manually stopped or times out. Valid values:

Process: stops the command process. ProcessTree: stops the process tree of the command, including the command process and all subprocesses.

ProcessTree

Launcher

string

No

The launcher for script execution. Must not exceed 1 KB in size.

python3 -u {{ACS::ScriptFileName|Ext(".py")}}

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

2FE2B22C-CF9D-59DE-BF63-DC9B9B33A9D1

InvokeId

string

The ID of the execution.

t-7d2a745b412b4601b2d47f6a768d*

Examples

Success response

JSON format

{
  "RequestId": "2FE2B22C-CF9D-59DE-BF63-DC9B9B33A9D1",
  "InvokeId": "t-7d2a745b412b4601b2d47f6a768d*"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.

阿里云首页 智能计算灵骏 相关技术圈