Thanx for this enlightening insight about cron jobs...
just a question.. when i run Optimize.php, i realise that you will echo some
statements. where will these statements be shown? since you put " >
/dev/null " instead of " > /dev/null 2>&1 ", does it mean that your echo
statements will be reflected in an email to me?
thanx.. i'm totally new to cron jobs, but thanx to sebastian's link on
crontab, i'm a little bit more knowledgable now! haha.. would appreciate
more insights! thanx!
----- Original Message -----
From: "Uzi Klein" <[EMAIL PROTECTED]>
To: "'Ng Hwee Hwee'" <[EMAIL PROTECTED]>; "'DBList'" <[EMAIL PROTECTED]>
Sent: Monday, May 03, 2004 6:32 PM
Subject: RE: [PHP-DB] Optimize Tables
> Use a cron job....
>
> Like:
>
> 0 0 * * * php Optimize.php > /dev/null
>
>
> This is an example for optimizing every table in all databases on your
mysql
> server.
>
> Optimize.php :
>
> <?php
> $db = mysql_connect("host", "user", "pass");
> $sql = "SHOW DATABASES";
> $dbs_result = mysql_query($sql, $db);
> if(mysql_num_rows($dbs_result))
> {
> while($dbs_row=mysql_fetch_assoc($dbs_result))
> {
> $database = $dbs_row["Database"];
> echo "\n\nOptimizing database $database : \n";
> mysql_select_db($database, $db);
> $sql = "SHOW TABLE STATUS";
> $tbls_result = mysql_query($sql, $db);
> if(mysql_num_rows($tbls_result))
> {
> while($tbls_row=mysql_fetch_assoc($tbls_result))
> {
> $TableName = "`".$tbls_row["Name"]."`";
> $sql = "REPAIR TABLE ".$TableName;
> echo "\n".$sql;
> mysql_query($sql, $db);
> $sql = "OPTIMIZE TABLE ".$TableName;
> echo "\n".$sql;
> mysql_query($sql, $db);
> }
> }
> }
> }
> echo "\n\n";
> mysql_close($db);
> ?>
>
>
> -----Original Message-----
> From: Ng Hwee Hwee [mailto:[EMAIL PROTECTED]
> Sent: Monday, May 03, 2004 11:19
> To: DBList
> Subject: [PHP-DB] Optimize Tables
>
> Hi,
>
> Is there a way to create a schedule to optimise my MySQL tables
> automatically? The overhead of some of my tables can reach 355,548 bytes
> over 3 working days!
>
> Please help me!
>
> Thanks.
> Hwee
>
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php