Find the process id of a java application in a bash script (to see if the target application is already running)
By default, pgrep
only matches the command, not the arguements. To match the full command line, you need the -f
option.
$ pgrep -f java_app
From the pgrep manpage:
-f The pattern is normally only matched against the process name. When -f is set, the full command line is used