A Simple Ruby Script to Gracefully Terminate System Processes
To gracefully terminate a system processes you issue the kill -15
command. You
then usually monitor the process to ensure that it terminates. If it does not,
you issue the kill -9
command to ensure that it does. Since this is a pretty
common task, I’ve created a simple Ruby script to automate it.
This script will issue the kill -15
command, monitor the process for up to 30
seconds to make sure it terminates, and if it still exists, issue the kill -9
command.
You can also call this script for multiple process ids: