How do I keep a Linux shell runner online after I log out of a remote SSH session?

Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.

Summary

You connect to a computer via SSH and start a Linux Shell self-hosted runner on that machine. After you leave the SSH session, the runner goes offline.

Environment

Linux Shell self-hosted runners in Bitbucket Pipelines

Solution

First solution

You can use one of the utilities screen or nohup, which are pre-installed in most Linux distributions, in order to keep the runner process running after exiting the SSH session.

In the following examples, replace <command to start runner> with the pre-configured command that starts the runner. This command is provided by Bitbucket when you create a new runner, and for Linux Shell runners it looks like this:

1 2 ./start.sh --accountUuid {<account id>} --repositoryUuid {<repository id>} --runnerUuid {<runner id>} --OAuthClientId <OAuthClient id> --OAuthClientSecret <OAuthClient secret> --runtime linux-shell --workingDirectory ../temp

Solution with screen:

In the terminal that is running the SSH session to the remote server, start the runner with the following command:

1 screen <command to start runner>

Then, press Ctrl + A and then Ctrl + D.

This will "detach" your screen session, but leave your process running, and you can leave your SSH session.

If you connect via SSH to the remote server at a later time, you can type screen -r to see the screen with the runner and Ctrl + A and Ctrl + D to detach again.

Solution with nohup:

In the terminal that is running the SSH session to the remote server, start the runner with the following command:

1 nohup <command to start runner> &

You can then leave the SSH session and the runner will remain online.

Second solution

Alternatively, you can configure the runner as a service. This way, the runner will also start automatically after a reboot of the remote server. Steps are provided in the following article:

Updated on February 26, 2025

Still need help?

The Atlassian Community is here for you.