Bamboo Agent stops on systemd when Script task hits OOM in Bamboo Data Center
Platform Notice: Data Center Only - This article only applies to Atlassian apps on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
When a Bamboo remote agent is installed as a systemd service, it may stop unexpectedly if a Script task or one of its child processes exhausts the available memory and is OOM-killed.
In this scenario, the build does not complete cleanly. Instead, the Bamboo agent process is terminated along with the Script task process, leaving the job in a stuck state until it is either stopped manually or handled by the build monitoring logic.
Diagnosis
If the following symptoms are present:
A Script task or one of its child processes consumes excessive memory.
The operating system records an OOM (Out of Memory) event in the kernel logs, for example:
[ 260.933456] oom-kill:constraint=CONSTRAINT_NONE,nodemask=(null),cpuset=docker-2db148a9921b2f36f95e783e4d89a946ada268407bc19aba4adf7ac288f249f4.scope,mems_allowed=0,global_oom,task_memcg=/system.slice/bamboo-agent.service,task=python3,pid=3439,uid=0
[ 260.933501] Out of memory: Killed process 3439 (python3) total-vm:3963008kB, anon-rss:3940736kB, file-rss:2560kB, shmem-rss:0kB, UID:0 pgtables:7792kB oom_score_adj:0The Bamboo agent service stops at the same time as the task process.
The build remains stuck rather than being marked as failed immediately.
The agent remains unavailable until the service is manually restarted.
The service status reports as
failed (Result: oom-kill):
× bamboo-agent.service - Bamboo Agent
Loaded: loaded (/etc/systemd/system/bamboo-agent.service; enabled; vendor preset: enabled)
Active: failed (Result: oom-kill) since Fri 2026-06-05 05:44:20 UTC; 4s ago
Process: 3177 ExecStart=/home/ubuntu/bamboo-agent-home/bin/bamboo-agent.sh start sysd (code=exited, status=0/SUCCESS)
Process: 3442 ExecStop=/home/ubuntu/bamboo-agent-home/bin/bamboo-agent.sh stop sysd (code=exited, status=0/SUCCESS)
Main PID: 3246 (code=exited, status=0/SUCCESS)
CPU: 25.111sCause
When a Bamboo agent is installed as a service, the service configuration file includes the setting KillMode=control-group by default. This means that if the kernel triggers an OOM (Out of Memory) kill, the impact can extend to the entire service cgroup, rather than being limited to the offending process alone.
When the Bamboo agent runs as a systemd service, the following processes all operate within the same control group (cgroup):
Tanuki wrapper — the service wrapper process
Bamboo agent Java process — the main agent runtime
Build task processes — such as Script tasks and any child processes they spawn
If a child process spawned by a Script task consumes excessive memory and triggers a kernel OOM kill, the consequences are not isolated to that single process. Due to the KillMode=control-group setting, all processes within the Bamboo agent's cgroup may be terminated abruptly, including the wrapper, the Java agent, and any other running tasks, not just the memory-hungry child process that caused the OOM event.
Solution
To prevent the entire Bamboo agent service from being terminated when a child process is OOM-killed, add the OOMPolicy=continue setting to the Bamboo agent's systemd service file by following the steps below.
Place
OOMPolicy=continueunder the[Service]section of the unit file (e.g.,/etc/systemd/system/bamboo-agent.service).The final service file should look similar to the following:
[Unit] Description=Bamboo Agent After=syslog.target [Service] Type=forking ExecStart=/home/ubuntu/bamboo-agent-home/bin/bamboo-agent.sh start sysd ExecStop=/home/ubuntu/bamboo-agent-home/bin/bamboo-agent.sh stop sysd OOMPolicy=continue KillMode=control-group Environment=SYSTEMD_KILLMODE_WARNING=true [Install] WantedBy=multi-user.targetAfter modifying the service file, reload the systemd daemon and restart the service for the changes to take effect:
systemctl daemon-reload systemctl restart bamboo-agent
How it works:
The OOMPolicy=continue instructs systemd not to treat an OOM event as a reason to stop the entire service. As a result:
The offending child process is terminated by the kernel.
The Bamboo agent process is still running and unaffected.
Bamboo can observe the task failure and capture the return code from the terminated process.
The job is marked as failed properly, instead of remaining stuck indefinitely.
The agent can continue accepting new builds without requiring a full service restart.
Was this helpful?