Sometimes we need to kill a bunch of processes. For example, we have run a plenty of PHP scripts from command line, and have noticed there are errors in them. Let’s say the wrong script is called php_script.php. Then in order to terminate all processes associated with script name, you need to issue the following command:
kill `ps aux | grep php_script.php | grep -v grep | awk '{print $2}'`
What does this command actually do? It sends process IDs found by ps to the kill command. Then all these processes are killed. This command is used when any other methods, like killall -9 php are not acceptable for any reason.
Related posts
“The team at Blisstering took personal pride in their development work, even to the point of augmenting the product with improvements and enhancements in order to deliver the best solution possible.”
Gale Wilson-Steele
Founder and CEO
CareSeek
“It was my first time using a website development company, and as much as I apprehended the whole process, it could not have been easier. At Blisstering, they made the whole process much less threatening than it seemed by being pleasant, cooperative, helpful, creative. They were quick to start work on our CRM solution, and to get it to completion -- on-time and on-budget. I love the final result! I strongly recommend Blisstering Solutions, and with pleasure.”
R. R. Shah
International Marketing Corporation