springboot-Simple ways to determine the PID of the springboot process

1. The purpose of this post

I would demo how to find or determine the PID of the springboot process.

2. Environments

  • springboot 1.x and 2.x

3. Simple ways to determine the PID of the springboot process

3.1 Way 1: Use ps command

If there is only a few java process in your machine, then you can use the following command to find it:

ps -ef|grep java

You would get a bunch of output about the java process:

 501 67826 65414   0 12:43PM ??         0:21.41 /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/bin/java -Dk1=v1 -Dspring.output.ansi.enabled=always -Didea.launcher.port=7532 -Didea.launcher.bin.path=/Applications/IntelliJ IDEA.app/Contents/bin -Dfile.encoding=UTF-8 -classpath /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre/lib/charsets.jar:/Library/Java/spring-webmvc-4.3.23.RELEASE.jar:/Users/zzz/.m2/repository/org/aspectj/aspectjweaver/1.8.12/aspectjweaver-1.8.12.jar:/Users/zzz/.m2/repository/com/zaxxer/HikariCP/3.2.0/HikariCP-3.2.0.jar:/Users/zzz/.m2/repository/org/springframework/boot/spring-boot-starter-actuator/1.5.20.RELEASE/spring-boot-starter-actuator-1.5.20.RELEASE.jar:/Users/zzz/.m2/repository/org/springframework/boot/spring-boot-actuator/1.5.20.RELEASE/spring-boot-actuator-1.5.20.RELEASE.jar:/Applications/IntelliJ IDEA.app/Contents/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain com.test.sb1jt.MainApp k2=v2 -k3=v3 --k4=v4

The PID is in the second column: 67826.

The cons of the way is that if there are many java processes, then the whole screen is occupied by the JVM informations, it’s too difficult to find the exact java process.

3.2 Way 2: Use jps command

Fortunately, JVM provides a jps command to display all java processes, simply run:


You would get:

67905 Jps
67897 Launcher
67898 AppMain

It’s more concise, but if you want more information to decide , there are some options you can use with jps:

-m Output the arguments passed to the main method. The output may be null for embedded JVMs.

-l Output the full package name for the application’s main class or the full path name to the application’s JAR file.

-v Output the arguments passed to the JVM.

-V Output the arguments passed to the JVM through the flags file (the .hotspotrc file or the file specified by the -XX:Flags= argument).

It’s useful to print the main method of every java process and the package of the main class. So ,we run this:

jps -l -m

You would get:

67922 sun.tools.jps.Jps -l -m
67897 org.jetbrains.jps.cmdline.Launcher /Applications/IntelliJ IDEA.app/Contents/lib/javac2.jar:....:/Applications/IntelliJ I
67898 com.intellij.rt.execution.application.AppMain com.test.sb1jt.MainApp k2=v2 -k3=v3 --k4=v4

It’s clear that our springboot process id is 67898