[EMAIL PROTECTED] wrote: > > Do MySQL server administrators recommend running a cron script daily > to isamchk? > > Is there any other things that should be run daily to keep MySQL > running top-notch? If so, does anyone have any pointers to a script > that has already been developed?
I actually find it helpful to periodically run the 'SHOW STATUS' command on the database and dump the results to a file. Examining this can give all sorts of information on how much use the database is getting, whether queries are optimized, etc. Documentation on the command is here: <http://www.mysql.com/doc/S/H/SHOW_STATUS.html>. I'm actually running this every half-hour, because I'm a freak. The script I use isn't exactly production quality (one of those ten-minute jobs). I keep intending to fix it someday or just use some internal MySQL statement that does the same thing, but I'm sure you know how it is. The script takes one parameter (a filename to dump results to). If called without one, it prints to STDOUT. Here's my code: #!/usr/local/bin/perl use strict; use DBI; my $filename = shift; my @time = localtime(); my $dbtype = 'mysql'; my $database = ''; # Insert your database's name here my $port = ''; # Insert your port here, or use a socket below my $dbuser = ''; # Some correctly set-up username my $dbpassword = ''; # The password for said name # Alternately, you could just hardcode everything into the connect # statement here. I have it broken up to make it easier for non-Perl # users to reconfigure the script. my $dbh = DBI->connect("DBI:$dbtype:database=$database;host=127.0.0.1;port=$port", $dbuser, $dbpassword); if (! $filename) { open (STATFILE, '>&STDOUT'); print STATFILE &makeheader(); } elsif (-f $filename) { open (STATFILE, ">>$filename"); } else { open (STATFILE, ">$filename"); print STATFILE &makeheader(); } printf STATFILE ('"%04d","%02d","%02d","%02d","%02d"', $time[5] + 1900, $time[4] + 1, $time[3], $time[2], $time[1]); my $sth = $dbh->prepare('show status'); $sth->execute; while (my $row = $sth->fetchrow_arrayref) { print STATFILE ",\"$row->[1]\""; } print STATFILE "\n"; close (STATFILE); $dbh->disconnect; ## END sub makeheader { my $outstring = '"Year","Month","Day","Hour","Minute"'; my $sth = $dbh->prepare('show status'); $sth->execute; while (my $row = $sth->fetchrow_arrayref) { $outstring .= ",\"$row->[0]\""; } $outstring .= "\n"; return ($outstring); } -- John Klein, Database Applications Developer | Omnia Mutantur, Systems Group - Harvard Law School | Nihil Interit --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <mysql-unsubscribe-##L=##[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php