2

I have installed the Azure DevOps agent on my Linux Ubuntu (Ubuntu 20.04.3 LTS) machine - https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/v2-linux?view=azure-devops.

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? Without API calls to Azure DevOps.

1
  • Try this: sudo ./svc.sh status. It need sudo. Commented Oct 26, 2022 at 16:23

1 Answer 1

1

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. If not, the return code will be 0, and you know, that there is not any job currently running on Agent. Otherwise, the return code of the command will be >=1.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.