skip to content

Daemon Management Commands

Inspecting daemons with --status, stopping them with --stop, the idle timeout, and where the registry lives. A practical question about cleaning up when a build behaves inconsistently.

on this pageshow

questions

5

How do you inspect which Gradle daemons are running and how do you stop them from the command line?

level: juniorimportance: must knowfreq 70%

answer

  1. --status lists PID/STATUS/version
  2. same-version only
  3. --stop = graceful, all compatible
  4. no single-daemon targeting
  5. registry.bin under GRADLE_USER_HOME/daemon

basics

~10 s

Run gradle --status to list daemons and their state, and gradle --stop to gracefully stop all idle and compatible daemons started by the current Gradle version.

solid answer

~30 s

`gradle --status` prints the daemons Gradle knows about: their PID, the Gradle version, their status (IDLE, BUSY) and uptime. It only lists daemons for the **same Gradle version** as the one you invoke, and skips daemons in unrecognised states. `gradle --stop` sends a graceful stop request to all daemons that the current version can talk to — they finish nothing in flight (idle ones exit, you cannot selectively stop one). Both commands read the daemon **registry** under `GRADLE_USER_HOME/daemon/<version>/registry.bin`. For a hard kill you fall back to the OS (`kill <pid>`), because `--stop` won't touch incompatible-version or stuck daemons.

code

bash · 8 lines
bash
# inspect daemons known to THIS gradle version
gradle --status

# stop all compatible daemons (graceful)
gradle --stop

# hard-kill a stuck or wrong-version daemon
kill <pid>   # PID from --status / OS tooling

go deeper

for a junior

Know the two commands and what they do: --status lists, --stop stops all.

for a middle

Add the same-version-only caveat and that --stop is graceful and all-or-nothing.

for a senior

Explain the registry backing both commands and when to fall back to an OS kill.

for a principal

Frame it as part of build-environment hygiene/diagnostics in CI and shared agents, and where the registry lives.

## What the daemon is, briefly The Gradle daemon is a long-lived background JVM that stays warm between builds so JIT-compiled code, the configured project model and caches survive. Because it is a separate process, Gradle ships CLI commands to **inspect** and **control** those processes without you hunting through the OS process list. ## `--status` ``` gradle --status ``` prints a table of the daemons Gradle currently knows about: - **PID** — the OS process id - **STATUS** — `IDLE` (waiting for work), `BUSY` (running a build), or `STOPPED`/`CANCELED` - **INFO** — the Gradle version and uptime Key nuance: `--status` only shows daemons started by the **same Gradle version** you invoke it with. If you have daemons from 8.5 and 8.7 around, `gradle --status` under 8.7 lists only the 8.7 ones. It also omits daemons whose state it cannot reliably read. ## `--stop` ``` gradle --stop ``` sends a **graceful** stop message to every daemon the current version can communicate with. Idle daemons shut down immediately; you cannot target a single daemon by PID through Gradle — it is all-or-nothing for compatible daemons. Stuck or wrong-version daemons are untouched, so for those you use the OS: ``` kill <pid> # unix taskkill /PID <pid> /F # windows ``` ## The registry Both commands are backed by the **daemon registry**, a small binary file at `GRADLE_USER_HOME/daemon/<gradleVersion>/registry.bin` (default `~/.gradle/daemon/...`). Each entry records the daemon's address, PID, and state. `--status` reads it; running builds and `--stop` update it. If the file is corrupt or stale, Gradle prunes dead entries on the next invocation. ## Why it matters In interviews and in CI you reach for these when a build behaves oddly: too many daemons eating RAM, a daemon pinned to an old version, or a hung build. `--status` diagnoses; `--stop` resets cleanly; the OS kill is the last resort.

  • Why might `--status` not list a daemon you know is running?
    Because it only reports daemons started by the same Gradle version, and it omits daemons whose state it can't read. A daemon from a different version, or a stuck/corrupt one, won't appear.
  • Can `--stop` target a single daemon?
    No. It gracefully stops all daemons compatible with the invoking version. To kill one specific PID you drop to the OS (`kill`/`taskkill`).

saying these in an interview costs you the question

  • Claiming `--stop` lets you stop one daemon by PID.
  • Assuming `--status` shows daemons from every Gradle version on the machine.

context

open as a page

How does the Gradle daemon's idle timeout work, and how do you configure it?

level: middleimportance: should knowfreq 45%

basics

~10 s

An idle daemon shuts itself down after a configurable period without builds — three hours by default. You change it with the org.gradle.daemon.idletimeout property, given in milliseconds.

open as a page

What does the `--no-daemon` flag do, and when would you actually use it?

level: middleimportance: should knowfreq 60%

basics

~10 s

--no-daemon runs the build in a single-use foreground JVM that exits when the build finishes, instead of reusing or spawning a persistent daemon. It's slower but fully isolated.

open as a page

A CI agent intermittently OOMs and a stale daemon is suspected. How would you use Gradle's daemon-management commands to diagnose and harden the setup?

level: seniorimportance: should knowfreq 30%

basics

~10 s

Use --status to see lingering daemons and their state, --stop to clear them between jobs, and harden by disabling the daemon (org.gradle.daemon=false) or shortening the idle timeout on long-lived agents.

open as a page

What is the Gradle daemon registry, where does it live, and how do `--status`/`--stop` use it?

level: seniorimportance: should knowfreq 35%

basics

~10 s

The registry is a small binary file (registry.bin) under GRADLE_USER_HOME/daemon/<version>/ tracking each daemon's address, PID and state. --status reads it; builds and --stop update it; dead entries are pruned automatically.

open as a page