Understanding process management with Ansible

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> ...

Get Hands-On Enterprise Automation on Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.