How To Repair Databases with Cronjob

ronowicker

Member
Aug 3, 2003
20
0
151
I'm hoping someone might have an easy solution with an issue I repeatedly have.

I have a few servers where I have cronjobs that add new news to drupal sites periodically through the day. That works fine and dandy. The problem that comes up from time to time is I get a database error that causes the site to stop working. Well I can get into WHM and run the "Repair a Database" function and it fixes the problem every time.

I'm wondering if there is a way I can setup "ONE" cronjob that will run this repair on "ALL" databases to fix any errors that might occur?

I do understand I can setup a cronjob for every database, but I'm hoping one of you really smart linux guys might know of a way to do this so I don't have to add a cronjob each time there is a new site added.

For example, to run a repair on one database it is something like this:

scripts/repairmysql?user=XXXXX&submit=Repair+Database

Is there a way to make it so the XXXXX is a "allusers" or even leave that part out so it goes methodically down the list and runs a repair on all of them?

I appreciate any help.
 

gupi

Well-Known Member
Apr 27, 2004
125
0
166
the command
Code:
mysqlcheck --check --all-databases --optimize
should do the job, if run as root.

short version: mysqlcheck -c -A -o
Anyway, check the man page for details.
 

motorspade

Registered
Sep 29, 2007
1
0
51
Venezuela
please, i really need the sript repair cron job

I´m a newbie, my web falls every night untill I manually enter c-panel and run repair db. It happens (web fail) always at the same hour. I need the code (script) to program a cron job repair. Please, is very urgent I need Vacations!! (The script posted in this forum didn't reapir my db, I had to manually repair it). Please help. Thanks.