PDA

View Full Version : Cron Job for MySQL


rentasite
05-24-2006, 11:40 AM
Hello to all.

What i want to do, and dont know how... is:

I want to run a cron job through my cPanel, that will optimize/repair a MySQL data base. Lets say, every 2 hours.

Can anyone plz help, telling me if and how can this be done? :)

Regards
Spiros

rentasite
05-26-2006, 11:06 PM
No one, to help? :(

charles
05-27-2006, 01:00 AM
If you need to repair a database every 2 hours, something is very very wrong.

There are lots of ways to go about this, but it could be as simple as

3 */2 * * * for t in `echo "show tables;" | mysql DBNAME | tail +2`; do echo "repair table $t;" | mysql DBNAME; done > /dev/null 2>&1

This assumes your user account has a ~/.my.cnf configured with the rights to run repair on the tables in the database DBNAME.

hth
charles