

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

# 驗證 CodeDeploy 代理程式是否正在執行
<a name="codedeploy-agent-operations-verify"></a>

本節說明如果您懷疑 CodeDeploy 代理程式已停止在執行個體上執行，要執行的命令。

**Topics**
+ [驗證 Amazon Linux 或 RHEL 的 CodeDeploy 代理程式是否正在執行](#codedeploy-agent-operations-verify-linux)
+ [驗證 Ubuntu Server 的 CodeDeploy 代理程式是否正在執行](#codedeploy-agent-operations-verify-ubuntu)
+ [驗證 Windows Server 的 CodeDeploy 代理程式是否正在執行](#codedeploy-agent-operations-verify-windows)

## 驗證 Amazon Linux 或 RHEL 的 CodeDeploy 代理程式是否正在執行
<a name="codedeploy-agent-operations-verify-linux"></a>

若要查看 CodeDeploy 代理程式是否已安裝並執行，請登入執行個體，然後執行下列命令：

```
systemctl status codedeploy-agent
```

如果命令傳回錯誤，則不會安裝 CodeDeploy 代理程式。按照 [安裝適用於 Amazon Linux 或 RHEL 的 CodeDeploy 代理程式](codedeploy-agent-operations-install-linux.md) 中的說明加以安裝。

如果已安裝並執行 CodeDeploy 代理程式，您應該會看到類似 `The AWS CodeDeploy agent is running.`（結束碼 0) 的訊息。

如果您看到類似 `The AWS CodeDeploy agent is not running.`（結束碼 3) 的訊息，請啟動服務並執行下列兩個命令，一次一個：

```
systemctl start codedeploy-agent
```

```
systemctl status codedeploy-agent
```

對於 2.0.x 版和更新版本，`codedeploy-agent status`命令會傳回與 LSB 相容的結束代碼： `0`（執行中）、 `3` （未執行）、 `4`（未知）。使用 時`systemctl status`，會顯示單位狀態 （例如 `Active: active (running)`)。

## 驗證 Ubuntu Server 的 CodeDeploy 代理程式是否正在執行
<a name="codedeploy-agent-operations-verify-ubuntu"></a>

若要查看 CodeDeploy 代理程式是否已安裝並執行，請登入執行個體，然後執行下列命令：

```
systemctl status codedeploy-agent
```

如果命令傳回錯誤，則不會安裝 CodeDeploy 代理程式。按照 [安裝適用於 Ubuntu Server 的 CodeDeploy 代理程式](codedeploy-agent-operations-install-ubuntu.md) 中的說明加以安裝。

如果已安裝並執行 CodeDeploy 代理程式，您應該會看到類似 `The AWS CodeDeploy agent is running.`（結束碼 0) 的訊息。

如果您看到類似 `The AWS CodeDeploy agent is not running.`（結束碼 3) 的訊息，請啟動服務並執行下列兩個命令，一次一個：

```
systemctl start codedeploy-agent
```

```
systemctl status codedeploy-agent
```

## 驗證 Windows Server 的 CodeDeploy 代理程式是否正在執行
<a name="codedeploy-agent-operations-verify-windows"></a>

若要查看 CodeDeploy 代理程式是否已安裝並執行，請登入執行個體，然後執行下列命令：

```
powershell.exe -Command Get-Service -Name codedeployagent
```

您應該會看到類似下列的輸出：

```
Status   Name               DisplayName
------   ----               -----------
Running codedeployagent    CodeDeploy Host Agent Service
```

如果命令傳回錯誤，則不會安裝 CodeDeploy 代理程式。按照 [安裝適用於 Windows Server 的 CodeDeploy 代理程式](codedeploy-agent-operations-install-windows.md) 中的說明加以安裝。

如果 `Status` 顯示 `Running` 以外的服務，請使用下列命令啟動服務：

```
powershell.exe -Command Start-Service -Name codedeployagent
```

您可以按照下列命令重新啟動服務：

```
powershell.exe -Command Restart-Service -Name codedeployagent
```

您可以按照下列命令停止服務：

```
powershell.exe -Command Stop-Service -Name codedeployagent
```