简体   繁体   English

如何通过 bash 检查 Linux 上自托管 Azure DevOps 代理上正在运行的作业

[英]How to check running job on self-hosted Azure DevOps Agent on Linux via bash

I have installed the Azure DevOps agent on my Linux Ubuntu (Ubuntu 20.04.3 LTS) machine - https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/v2-linux?view=azure-devops .我已经在我的 Linux Ubuntu(Ubuntu 20.04.3 LTS)机器上安装了 Azure DevOps 代理 - https://docs.microsoft.com/en-us/azure/devops/pipelines/agents/v2-linux?view=azure-开发者

Now I want to write a script, which will check if there is some job (pipeline) running on an agent.现在我想编写一个脚本,它将检查代理上是否有一些作业(管道)正在运行。

Is it possible to somehow check whether there is a job running on the agent via bash on Linux, where is the agent installed?是否可以通过 Linux 上的 bash 以某种方式检查代理上是否正在运行作业,代理安装在哪里? Without API calls to Azure DevOps.没有对 Azure DevOps 的 API 调用。

I found a solution by reading the status of the agent service:我通过阅读代理服务的状态找到了解决方案:

Go to folder where you installed the agent and run -转到安装代理的文件夹并运行 -

./svc.sh status | tail -n1 | grep -c -e "Running"

  1. Get the agent status获取代理状态
  2. Get the last line获取最后一行
  3. Check if the last line contains the word Running .检查最后一行是否包含单词Running If not, the return code will be 0, and you know, that there is not any job currently running on Agent.如果不是,则返回码将为 0,并且您知道,代理上当前没有任何作业正在运行。 Otherwise, the return code of the command will be >=1.否则,命令的返回码将 >=1。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为 Azure devops 服务器安装自托管 Linux 代理 - Installing Self Hosted Linux Agent for Azure devops Server Azure DevOps:“托管Linux预览”和“托管Ubuntu 1604”代理池之间有什么区别? - Azure DevOps: What's the difference between the “Hosted Linux Preview” and “Hosted Ubuntu 1604” agent pools? Azure Devops 管道,知道管道何时完成的方法,使用自托管代理 - Azure Devops pipeline , way to know when pipeline is done , using self hosted agent 在Hosted Linux Agent上运行VSTS构建期间挂载Azure文件存储失败 - Mounting Azure file storage during VSTS build running on Hosted Linux Agent fails 如何检查 ssh-agent 是否已经在 bash 中运行? - How to check if ssh-agent is already running in bash? 如何为基于 linux 的数据库服务器设置 Azure 自托管集成运行时 - How to setup Azure self hosted integration runtime for linux based db servers 如果您不想在 root 上运行,为什么 Linux 自托管运行器上的 Github 操作需要用户交换每个命令 - Why does a Github Action on a Linux self-hosted runner require a user swap for every command if you dont want to run on root 在Linux托管代理上找不到Dockerfile - Dockerfile not found on Linux hosted agent 如何找到正确的托管代理来构建Linux代码? - How to find correct hosted agent to build Linux code? 如何通过bash查询Linux Mint中运行bash脚本的虚拟桌面数量? - How can I query the number of the virtual desktop on which the bash script is running in Linux Mint via bash?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM