Reputation: 6867
I've this running java process:
testuser 37126 1 0 2018 ? 01:56:24 java -jar backend76465465.jar -XX:-OmitStackTraceInFastThrow --spring.profiles.active=server
I want to dynamically get its pid based on :
a part of its name: "backend"
(which is the fix part "backend") ,
the other part : 76465465 would always change i ve tried this :
ps -eaf | awk '$NF~"backend" {print $2}'
and this :
ps -eaf | grep java | awk '$NF~"backend" {print $2}'
but it still give me empty results .
Suggestions ?
Upvotes: 0
Views: 104
Reputation: 4574
Try pgrep
, it will return the pid of the matched process :
pgrep -f backend
Upvotes: 3