09-28-2011, 12:08 AM
(09-24-2011, 01:28 AM)Gaijin Wrote: I assume you already know how to setup the cron and get it to work, so here would be your script...
PHP Code:<?php
if(!$con = mysql_connect('locahost', 'user', 'pass'))
{
die('Cannot connect!');
}
$tables = mysql_query('SHOW TABLES', $con) or die('SHOW TABLES ERROR');
while($table = mysql_fetch_row($tables))
{
mysql_query("OPTIMIZE TABLE {$table[0]}") or die(mysql_error());
}
mysql_close($con)
?>
You might also want to check out commands such as, clean and repair...
thanks for the script. note that in case anyone else wants to use this, they'll need to fix "locahost" in your original code to read "localhost".
if the script is showing this, and only this, on the screen (SHOW TABLES ERROR), does that mean it failed or did it run successfully?