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.
- 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:
You would get a bunch of output about the java process:
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:
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=
It’s useful to print the main method of every java process and the package of the main class. So ,we run this:
You would get:
It’s clear that our springboot process id is 67898