Start script:
shell_exec("/usr/bin/php /var/www/bot.php & ");
echo "Bot Started Successfully";
Stop Script: (some code is borrowed from the php manual thanks to Ashraf M Kaabi)
function kill($PID){
if(is_running($PID)){
exec("kill -KILL$PID");
return true;
}else return false;
}
function is_running($PID){
exec("ps $PID", $ProcessState);
return(count($ProcessState) >= 2);
}
$output = shell_exec("ps | grep php | awk '{print $1}'");
if ($output != null) {
kill($output);
echo "Killed process id:/" $output /"";
} else {
echo "Output Null";
}
No comments:
Post a Comment