Sooner or later, you will end up with the need to manage, and possibly even kill, processes on one or more Linux servers within your enterprise. Obviously, this is not an ideal scenario, and in day-to-day operations, most services should be managed using the Ansible service module, many examples of which we have seen in this book.
What if, however, you need to actually kill a service that has hung? Obviously, a system administrator could SSH into the errant server and issue commands such as the following:
$ ps -ef | grep <processname> | grep -v grep | awk '{print $2}'
$ kill <PID1> <PID2>
If the process refuses stubbornly to terminate, then the following may become necessary:
$ kill -9 <PID1> <PID2>
While this is a fairly standard practice, in which most system administrators will be well versed...