Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

How To Repair Databases with Cronjob

Discussion in 'General Discussion' started by ronowicker, Jan 4, 2007.

  1. ronowicker

    ronowicker Member

    Aug 3, 2003
    Likes Received:
    Trophy Points:
    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:


    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.
  2. gupi

    gupi Well-Known Member

    Apr 27, 2004
    Likes Received:
    Trophy Points:
    the command
    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.
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. motorspade

    motorspade Registered

    Sep 29, 2007
    Likes Received:
    Trophy Points:
    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.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice