首页 > 代码库 > php结合linux 执行通道关闭重启
php结合linux 执行通道关闭重启
<?php
if( $_SERVER[‘REMOTE_ADDR‘]!=‘‘ ) DIE;
$curFile = __FILE__;
$ROOT = dirname($curFile);
include $ROOT."/config.cron.php";
$caefile=CACHE."/channel.cae.php";
$exp = explode(‘case/‘,$curFile);
$runFile = $exp[1];
exec("ps xau | grep cron_send | grep -v grep | awk ‘{print $12\"__\"$2}‘",$row);
foreach($row as $file)
{
$file = trim($file);
list($file,$kid) = explode(‘__‘,$file);
if($file)
{
$exp = explode(‘case/‘,$file);
$files[$exp[1]]=$kid;
}
}
$cjfile = $ROOT.‘/jc.php‘;
echo $cjfile.‘=======‘;
$cFiles = file($cjfile);
unlink($cjfile);
foreach( $cFiles as $kf )
{
$kf = trim($kf);
list($f,$s) = explode(‘__‘,$kf);
$exp = explode(‘case/‘,$f);
if( $s==‘1‘ && $f )//重启
{
echo $exec = "nohup /usr/local/php5/bin/php {$f} > /opt/null &";
system($exec);
}
else if( $s==‘0‘ ) //关闭
{
$kid = $files[$exp[1]];
echo $exec = "kill $kid";
exec($exec);
}
}
if( $files[$runFile]>1 )
{
die(‘已经运行中,当前无法启动....‘);
}
?>