How do I kill a running background program with PHP?

I have a button in my program that when pressed, runs this line of code.

ps -eo pid,command | grep "test-usb20X" | grep -v grep | awk '{print $1}'

It gives me the correct pid output. For example, “3243”.

What I want to do now is kill that pid. I would just write

exec("kill -9 3232");

But the pid changes, so how do I save that number to a variable and then use it in the kill line?


Source: php

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.