RunCommand

Updated at:

Executes 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 name of the command.

testName

Description

string

No

The description of the command.

testDescription

CommandContent

string

No

The content of the command. Take note of the following items:

  • If you set EnableParameter to true, custom parameters are enabled in the command content.

  • Custom parameters are enclosed in {{}}. Spaces and line breaks before and after the parameter names in {{}} are ignored.

  • You can specify up to 20 custom parameters.

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

  • A custom parameter name cannot exceed 64 bytes in length.

ZWNobyAxMjM=

Timeout

integer

No

The timeout period for executing the command, in seconds. A timeout occurs when the command cannot be executed due to process issues, missing modules, or missing Cloud Assistant Agent. After a timeout, the command process is forcibly terminated. Default value: 60.

3600

WorkingDir

string

No

You can customize the execution path of the command. Default paths:

Linux instances: The default execution path is the /home directory of the root user.

/home/user

EnableParameter

boolean

No

Specifies whether the command contains custom parameters.

Default value: false.

false

ContentEncoding

string

No

The encoding format of the script content. Valid values:

  • PlainText: The content is not encoded and is transmitted in plaintext.

  • Base64: The content is Base64-encoded.

Default value: PlainText. If you specify an invalid value, the value is processed as PlainText.

Base64

Username

string

No

The name of the user that executes the command on the instance. The name cannot exceed 255 characters in length. For Linux instances, the default user is root.

root

NodeIdList

array

No

The list of nodes. Array length: 1 to 100. The node IDs must belong to created Lingjun nodes. You can call the ListClusterNodes or ListFreeNodes operation to query the node IDs.

string

No

The node ID.

e01-cn-zvp2tgykr08

RepeatMode

string

No

The execution mode of the command. Valid values:

  • Once: Executes the command immediately.

  • Period: Executes the command on a schedule. If you set this parameter to Period, you must also specify the Frequency parameter.

  • NextRebootOnly: Automatically executes the command the next time the instance starts.

  • EveryReboot: Automatically executes the command every time the instance starts.

Default value:

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

  • If you specify the Frequency parameter, the value is processed as Period regardless of whether this parameter is specified.

Once

ClientToken

string

No

The client token that is used to ensure the idempotence of the request. You can use the client to generate the value, but you must make sure that the value is unique among different requests. 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 for executing the command. Three scheduling methods are supported: execution at fixed intervals (based on Rate expressions), one-time execution at a specified time, and clock-based scheduled execution (based on Cron expressions).

  • Execution at fixed intervals: Uses a Rate expression to execute the command at a specified interval. The interval can be specified in seconds (s), minutes (m), hours (h), or days (d). This method is suitable for scenarios where tasks are executed at fixed intervals. The format is rate(<interval value><interval unit>). For example, to execute the command every 5 minutes, use rate(5m). Limits on fixed-interval execution:

    • The interval cannot exceed 7 days or be less than 60 seconds, and must be greater than the timeout period of the scheduled task.

    • The execution interval is based only on the fixed frequency and is independent of the actual time required to execute the task. For example, if you set the interval to 5 minutes and the task takes 2 minutes to complete, the next execution starts 3 minutes after the task is completed.

    • The task is not executed immediately upon creation. For example, if you set the interval to 5 minutes, the command is not executed immediately when the task is created. Instead, the first execution starts 5 minutes after the task is created.

  • One-time execution at a specified time: Executes the command once at the specified time zone and time. The format is at(yyyy-MM-dd HH:mm:ss <time zone>). If you do not specify a time zone, the UTC time zone is used by default. The time zone supports the following three formats: Full name of the time zone, such as Asia/Shanghai and America/Los_Angeles. Offset of the time zone from Greenwich Mean Time (GMT), such as GMT+8:00 and GMT-7:00. When you use the GMT format, leading zeros are not supported for the hour. Time zone abbreviation: Only UTC is supported. For example, to execute the command once at 13:15:30 on June 6, 2022 in the Asia/Shanghai time zone, use at(2022-06-06 13:15:30 Asia/Shanghai). To execute the command once at 13:15:30 on June 6, 2022 in the GMT-7:00 time zone, use at(2022-06-06 13:15:30 GMT-7:00).

  • Clock-based scheduled execution (based on Cron expressions): Uses a Cron expression to execute the command on a schedule. The format is <seconds> <minutes> <hours> <day of month> <month> <day of week> <year (optional)> <time zone>, which is <Cron expression> <time zone>. The execution time is calculated based on the Cron expression in the specified time zone. If you do not specify a time zone, the system time zone of the instance where the scheduled task runs is used by default. For more information about Cron expressions, see Cron expressions. The time zone supports the following three formats:

    • Full name of the time zone, such as Asia/Shanghai and America/Los_Angeles.

    • Offset of the time zone from GMT, such as GMT+8:00 and GMT-7:00. When you use the GMT format, leading zeros are not supported for the hour.

    • Time zone abbreviation: Only UTC is supported.

    For example, to execute the command once at 10:15 every day in 2022 in the Asia/Shanghai time zone, use 0 15 10 ? * * 2022 Asia/Shanghai. To execute the command every 30 minutes from 10:00 to 11:30 every day in 2022 in the GMT+8:00 time zone, use 0 0/30 10-11 * * ? 2022 GMT+8:00. To execute the command every 5 minutes from 14:00 to 14:55 every day in October every two years starting from 2022 in the UTC time zone, use 0 0/5 14 * 10 ? 2022/2 UTC.

0 */20 * * * ?

Parameters

object

No

The key-value pairs of custom parameters that are passed when the command is executed, if the command contains custom parameters. For example, if the command content is echo {{name}}, you can pass the key-value pair {"name":"Jack"} by using the Parameter parameter. The custom parameter automatically replaces the variable name, generating a new command echo Jack to be executed.

You can specify 0 to 10 custom parameters. Take note of the following items:

  • The key cannot be an empty string and can contain up to 64 characters.

  • The value can be an empty string.

  • After the custom parameters and the original command content are Base64-encoded, if you save the command, the size of the Base64-encoded command content cannot exceed 18 KB. If you do not save the command, the size cannot exceed 24 KB. You can use KeepCommand to specify whether to retain the command.

  • The set of custom parameter names must be a subset of the parameter set defined when the command is created. For parameters that are not passed, you can use empty strings.

Default value: empty. An empty value indicates that this parameter is not specified and custom parameters are disabled.

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

CommandId

string

No

The ID of the command.

c-e996287206324975b5fbe1d***

TerminationMode

string

No

The mode used when the task is stopped manually or interrupted due to an execution timeout. Valid values:

Process: Stops the current script process. ProcessTree: Stops the current process tree, which is the collection of the script process and all child processes created by it.

ProcessTree

Launcher

string

No

The launcher for script execution. The size cannot exceed 1 KB.

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

Response elements

Element

Type

Description

Example

object

RequestId

string

Id of the request

2FE2B22C-CF9D-59DE-BF63-DC9B9B33A9D1

InvokeId

string

The invocation ID.

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.