I'm trying to kill any process that has to do with mysql. I'm piecing together a command, and so far, haven't come up with the right solution. One other consideration, is that the last process will correspond to the command 'grep mysql' - part of the command below. This process won't exist anymore by the time I try to kill it, so it needs to be excluded from the input piped to kill -9. Whats the best way to go about accomplishing this task? So far, I have the incomplete command:
ps -A | grep mysql | awk '{print $1}'
which has the (fake, for the purpose of this example) output
11111
22222
33333 # process id to be excluded
I was assuming I could pipe that to xargs kill -9 like so:
ps -A | grep mysql | awk '{print $1}' | xargs kill -9
and figure out a way to exclude the last pid, but everything I try does not seem to work correctly.