選取您的 Cookie 偏好設定

我們使用提供自身網站和服務所需的基本 Cookie 和類似工具。我們使用效能 Cookie 收集匿名統計資料,以便了解客戶如何使用我們的網站並進行改進。基本 Cookie 無法停用,但可以按一下「自訂」或「拒絕」以拒絕效能 Cookie。

如果您同意,AWS 與經核准的第三方也會使用 Cookie 提供實用的網站功能、記住您的偏好設定,並顯示相關內容,包括相關廣告。若要接受或拒絕所有非必要 Cookie,請按一下「接受」或「拒絕」。若要進行更詳細的選擇,請按一下「自訂」。

UpdateComputeEnvironment 搭配 AWS SDK 或 CLI 使用 - AWS SDK 程式碼範例

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

文件 AWS 開發套件範例 GitHub 儲存庫中有更多可用的 AWS SDK 範例

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

UpdateComputeEnvironment 搭配 AWS SDK 或 CLI 使用

下列程式碼範例示範如何使用 UpdateComputeEnvironment

動作範例是大型程式的程式碼摘錄,必須在內容中執行。您可以在下列程式碼範例的內容中看到此動作:

CLI
AWS CLI

更新運算環境

此範例會停用 P2OnDemand 運算環境,以便將其刪除。

命令:

aws batch update-compute-environment --compute-environment P2OnDemand --state DISABLED

輸出:

{ "computeEnvironmentName": "P2OnDemand", "computeEnvironmentArn": "arn:aws:batch:us-east-1:012345678910:compute-environment/P2OnDemand" }
Java
SDK for Java 2.x
注意

GitHub 上提供更多範例。尋找完整範例,並了解如何在 AWS 程式碼範例儲存庫中設定和執行。

/** * Disables the specified compute environment asynchronously. * * @param computeEnvironmentName the name of the compute environment to disable * @return a CompletableFuture that completes when the compute environment is disabled */ public CompletableFuture<UpdateComputeEnvironmentResponse> disableComputeEnvironmentAsync(String computeEnvironmentName) { UpdateComputeEnvironmentRequest updateRequest = UpdateComputeEnvironmentRequest.builder() .computeEnvironment(computeEnvironmentName) .state(CEState.DISABLED) .build(); CompletableFuture<UpdateComputeEnvironmentResponse> responseFuture = getAsyncClient().updateComputeEnvironment(updateRequest); responseFuture.whenComplete((response, ex) -> { if (ex != null) { throw new RuntimeException("Failed to disable compute environment: " + ex.getMessage(), ex); } }); return responseFuture; }
AWS CLI

更新運算環境

此範例會停用 P2OnDemand 運算環境,以便將其刪除。

命令:

aws batch update-compute-environment --compute-environment P2OnDemand --state DISABLED

輸出:

{ "computeEnvironmentName": "P2OnDemand", "computeEnvironmentArn": "arn:aws:batch:us-east-1:012345678910:compute-environment/P2OnDemand" }

下一個主題:

UpdateJobQueue

上一個主題:

SubmitJob
隱私權網站條款Cookie 偏好設定
© 2025, Amazon Web Services, Inc.或其附屬公司。保留所有權利。