How to get only process ID in specify process name in linux?
You can pipe your output to awk to print just the PID. For example:
ps -ef | grep nginx | awk '{print $2}' 9439
You can use:
ps -ef | grep '[j]ava'
Or if pgrep
is available then better to use:
pgrep -f java