I'm writing a script to stop an application. Sometimes the application doesn't want to stop. So after a several minute pause, if the application is still running I want to kill it. After a number of failures of the kill command, I tried adding the -9 to force stop it. This doesn't seem to work. Does anyone know how I can get this to function, even if I need to use a different command, I'm open to new things. :-)Following is my command line:ps -ef|grep -v grep|grep <process_name>|awk -F' ' '{print $2}' |xargs kill -9Thanks in advance.
passing a '-9' to xargs kill command
rhel;kill;xargs
@muru was correct, but lately I've found that using the '-f' option to pkill is preferred. Matches against the entire process and argument list. Here we have a few servers running Tomcat processes and Logstash (sending data to Elastic). So 'kill -9 java' to stop the Tomcat process also kills the Logstash process.pkill -9 -f 'pattern to match'Example:pkill -9 -f '/opt/tomcat/'