I'm creating a shell script ( that will be called by a cron) that will kill a process 'openjms' but i don't know how to go about killing it. Usually i grep for the process and get the process ID and kill it manually
ps -wwwef | grep openjms
root 3511 1 0 01:10 ? 00:00:00 /bin/sh ./openjms.sh start
root 3517 3511 11 01:10 ? 01:02:26 /opt/third-party/pkg/java-1.4.2_06_SUN/bin/java -Dopenjms.home=/usr/local/openjms-0.7.5 -classpath /usr/local/openjms-0.7.5/lib/ext/mysql-connector-java-5.0.4-bin.jar:/usr/local/openjms-0.7.5/lib/openjms-0.7.5.jar -Djava.security.manager -Djava.security.policy=/usr/local/openjms-0.7.5/src/etc/openjms.policy org.exolab.jms.server.JmsServer
kill -9 3511 3517
When i have to kill it a second time obviously the process id will change so i have to grep and do it again.
but it says
openjms: no process killed
Is there a way to search for process id of openjms and then kill it, in an automated way?