firasKoubaa
firasKoubaa

Reputation: 6867

Shell : How to get pid given apart of its name string

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 :

and this :

ps -eaf | grep java | awk '$NF~"backend" {print $2}'

but it still give me empty results .

Suggestions ?

Upvotes: 0

Views: 104

Answers (2)

Penny Liu
Penny Liu

Reputation: 17428

Have you tried to use ps aux | grep backend?

Upvotes: 0

nullPointer
nullPointer

Reputation: 4574

Try pgrep , it will return the pid of the matched process :

pgrep -f backend

Upvotes: 3

Related Questions