Location: PHPKode > projects > web-cp - Web Hosting Control Panel > webcp/server/cron/logrotate.inc.phps
<? // create necessary files on the fly for log rotation (keeps up to date)

unset($domainslog);

// Generate log rotate for all domains
$dbp = mysql_query("SELECT host,domain,path,id FROM domains WHERE type='domain' OR type='subdomain'");
while ($data = mysql_fetch_array($dbp)) {
	$access_log = $data['path']."/".$data['host']."/logs/access";
	$error_log = $data['path']."/".$data['host']."/logs/error";
	$stats = $data['path']."/".$data['host']."/".$cfg['webname']."/stats";
	$dom = $data['domain'];
	$host = $data['host'];
	$domainslog .= "$access_log {
	prerotate
		".$cfg['prog']['walizer']." -Q -p -n $host.$dom -o $stats -R 50 -S 50 -U 50 $access_log
	endscript
	missingok
	size 50M
	compress
	sharedscripts
}

$error_log {
	missingok
	size 10M
	compress
}

";
}

// add log rotate info for the webcp http server, restart both web servers
$serverlog = $cfg['basedir']."/httpd/logs/access ";
$serverlog .= $cfg['basedir']."/httpd/logs/access_log ";
$serverlog .= $cfg['basedir']."/httpd/logs/error ";
$serverlog .= $cfg['basedir']."/httpd/logs/error_log";
$serverlog .= " {
	missingok
	size 50M
	compress
	sharedscripts
	postrotate
		".$cfg['init']['httpd-cp']." stop
		".$cfg['init']['httpd']." stop
		".$cfg['init']['httpd-cp']." start
		".$cfg['init']['httpd']." start
	endscript
}
";
if ($cfg['log_system'] == 'file' OR $cfg['log_system'] == 'filedb') {
$serverlog .= $cfg['logfile']." {
	missingok
	size 5M
	compress
	sharedscripts
}
";
}
// write file in logrotate.d dir
$fp = fopen($cfg['logdir']."webcp_domains","w+");
fwrite($fp,$domainslog.$serverlog);
fclose($fp);
?>
Return current item: web-cp - Web Hosting Control Panel