Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kill all Gradle Daemons Regardless Version?

Summary

I would like to know how to kill every single gradle daemon and process running on a machine regardless of the version of gradle or the version of the daemon, but the "--kill" or "--stop" command will only stop those processes that match the same version of gradle.

Use case

My CI build box will have several gradle daemons running with different versions (because I'm a good boy that uses the wrapper to execute builds). Occasionally I will find issues with caching or incremental builds, and as a precaution I like to kill the daemons. The same is true for my development boxes, although the conflicts are more often with whichever VCS or IDE I am using.

What I am looking for

  1. I'm hoping there is a flag or property I am missing that I could pass to gradle to do this in a simple one line command, but if it's simple enough I would be ok with more.
  2. No scripting (looping, if-else etc).
  3. Killing all java processes is not acceptable.

Helpful links to the gradle docs

Disabling the Daemon

Stopping an existing Daemon

like image 420
Pytry Avatar asked Jan 14 '19 21:01

Pytry


People also ask

How do I kill a Gradle process in Windows?

If you wish to stop a Daemon process manually, you can either kill the process via your operating system task manager or run the gradle --stop command. The --stop switch causes Gradle to request that all running Daemon processes, of the same Gradle version used to run the command, terminate themselves.

How do I stop Gradle daemon in IntelliJ?

IntelliJ interacts with Gradle via the Gradle tooling API, which always uses the daemon. i.e. There is no way to turn it off. "gradle idea" is needed only to generate the required files. Though the recent versions of Idea use "directory-based" project structure, so the file generation is no longer necessary.


1 Answers

Under linux you may use pkill:

pkill -f '.*GradleDaemon.*' 

Under windows you may use wmic:

WMIC PROCESS where "Name like 'java%' AND CommandLine like '%GradleDaemon%'" Call Terminate 

PS. Why "no scripting" when it is probably the easiest solution?

like image 83
Nikita Tukkel Avatar answered Oct 08 '22 14:10

Nikita Tukkel