Linux Unix MySQL MSSQL Windows Virtuozzo MRTG SNMP SMTP ASP.NET PHP IIS News IT Apache Parallels Plesk CommuniGate GNU GNOME KDE Solaris HP-UX FreeBSD RedHat Fedora CentOS Howto Database Replication Disaster Recovery High Availability High Performance Cluster Dynamic Cluster HTTP Proxy Squid Email Groupware Collaboration Instant Messenger Voice over IP VoIP IPSec Tunnel VPN Sniffer Software System Engineer Programmer Programming Certified SSL PKI Authentication script
Saturday, February 4, 2012
Clean up cache and log for magento
Create cleanup.php file in document root folder then put these code to it, edit database variables, save and run cleanup.php?clean=log or cleanup.php?clean=var
<?
$db['host'] = ''; // Database hostname
$db['name'] = ''; // Database name
$db['user'] = ''; // Database username
$db['pass'] = ''; // Database password
$db['pref'] = ''; // Database tables' prefix
if($_GET['clean'] == 'log') clean_log_tables();
if($_GET['clean'] == 'var') clean_var_directory();
function clean_log_tables() {
global $db;
$tables = array(
'log_url',
'log_url_info',
'log_visitor',
'log_visitor_info'
);
mysql_connect($db['host'], $db['user'], $db['pass']) or die(mysql_error());
mysql_select_db($db['name']) or die(mysql_error());
foreach($tables as $v => $k) {
mysql_query('TRUNCATE `'.$db['pref'].$k.'`') or die(mysql_error());
}
}
function clean_var_directory() {
$dirs = array(
'var/cache/',
'var/log/',
'var/report/',
'var/session/',
'var/tmp/',
'downloader/pearlib/cache/*',
'downloader/pearlib/download/*'
);
foreach($dirs as $v => $k) {
exec('rm -rf '.$k);
}
}
?>
Reference: http://www.magentocommerce.com/boards/viewthread/36148/#t117754
No comments:
Post a Comment