OK...
PHP-Code:
<?php
set_time_limit(100);
$time = microtime(true);
$start = $time;
//Mysqlconnection :
$h = 'localhost';
$u = 'root';
$p = 'xxx';
$dummy_db = 'mysql';
/**/
$msg = "DB Optimierung\n\n";
$db_link = mysql_connect($h, $u, $p) or die("Cannot connect do server");
mysql_select_db($dummy_db) or die("Cannot select the DB");
while ($rec = mysql_fetch_array($res)){
$dbname = $rec[0];
$msg .= "DB : $db_name\n";
$sql = "SHOW TABLE STATUS FROM $db_name";
$res = mysql_query($sql) or die('Query : ' . mysql_error());
while ($rec = mysql_fetch_array($res)){
$msg .= sprintf("%30s wurde optimiert\n", $rec['Name']);
if ($rec['Data_free'] > 0){
$tbl = $rec['Name'];
$sql = "OPTIMIZE TABLE $tbl";
mysql_db_query($sql) or die(mysql_error());
}
}
}
$time = microtime(true);
$finish = $time;
$total_time = round(($finish - $start), 6);
$msg .= "Parsed in $total_time secs\n\n";
echo nl2br($msg);
$empf = 'empfaenger@mail.com';
$betreff = "Optimierungsstatistik";
mail($empf, $betreff, $msg);
?>
Kommentar