Actually I don't think pgrep will work for this reliably - here's what I
get:
root@solr-berkshelf:# pgrep jetty# echo $?
root@solr-berkshelf:
1
root@solr-berkshelf:# ps aux | grep -w jetty | grep -qv grep# echo $?
root@solr-berkshelf:
0
root@solr-berkshelf:~# ps aux | grep -w jetty | grep -v grep
jetty 12169 0.4 23.3 1543184 87252 ? Sl Apr03 1:12 /usr/bin/java -Dsolr.solr.home=/opt/solr -Djetty.port=8085 -Djetty.home=/opt/jetty -Djava.io.tmpdir=/tmp -jar /opt/jetty/start.jar --pre=etc/jetty-logging.xml --daemon
Doing it this way is one way to check and see if a process is there - that's not a usual process - pgrep works great with things like ssh:
root@solr-berkshelf:~# pgrep sshd
1211
11206
11226
But it doesn't find my jetty process - because it's run under java. It does find java:
vagrant@solr-berkshelf:~$ pgrep java
12169
I suppose we could use grep with [j]etty - that would work too.