How to execute a step in the background on CircleCI

If you want to monitor what is happening while running a job on CircleCI you can do this using a background step that will run alongside your other steps using background: true.

A step that has background: true set will run while there are other steps running but once they have finished the background step will also end, it will not run on its own if there are no other steps.


The following code will run as an infinite loop printing the text from the echo command every five seconds as a background steps. Replacing the echo command will allow any command to run every 5 seconds. You can also set any step to run the background by adding the background: true to the end of the step as shown in the example below.

- run:
command: |
while true; do
echo "this in running in the background"
background: true


Any step which is set with background: true will continue to run in the background while other steps are running showing any output that you have defined.

Additional Resources

The following link is specifically for recording memory usage using the background: true setting:

The following link is for the CircleCI documentation for background commands:

Was this article helpful?
0 out of 2 found this helpful



Article is closed for comments.