try something like this:
put this in a php file
<?php
$running_ps = shell_exec('ps -afx | grep php');//get the php processes
if(preg_match_all('/([0-9]+)(.*?)php (201)/', $running_ps, $a_matches)) {//identify the proces you need
foreach ($a_matches[1] as $key => $value) {
$a_running_proc = $value;
}
}
if (isset($_REQUEST['action'])) {
if($_REQUEST['action'] == '0' ) {
//stop the process
proc_close(proc_open('kill '. $a_running_proc, array(), $foo));//kill the process
}
else
{
//do whatever you want to do
//then start the process again
proc_close(proc_open("php [script_file_name] 201 &", array(), $foo));//run the process in background
}
?>
and here is the html
<html>
<body>
<a href="[script_file_name]?action=1"><button>Start</button></a>
<a href="[script_file_name]?action=0"><button>Stop</button></a>
</body>
</html>