Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Just as above, I increased the RAM (it's a VM), but that doesn't give me a safety net. I was under the impression by default it should respawn, but that doesn't seem to be the case.

*Ubuntu 10.04

Any suggestions?

share|improve this question
    
Does this help? –  DevNull Feb 20 at 13:40

1 Answer 1

Credit from: http://askubuntu.com/a/451889

Create a script to check status and start if not found:

    #!/bin/bash
    if [[ ! "$(/usr/sbin/service mysql status)" =~ "start/running" ]]
    then
        /usr/sbin/service mysql start
    fi

Make sure script is executable:

    chmod +x /path/to/script

Finally create a cron to run the script:

    sudo crontab -e

And add (one of) the following lines to the crontab:

    */1 * * * * /path/to/script  ### Every Minute
    */5 * * * * /path/to/script  ### Every 5 minutes
    */10 * * * * /path/to/script ### Every 10 minutes
    */30 * * * * /path/to/script ### Every 30 minutes
    0 * * * * /path/to/script    ### Every hour

 # * * * * *  command to execute
 # │ │ │ │ │
 # │ │ │ │ │
 # │ │ │ │ └───── day of week (0 - 6) (0 to 6 are Sunday to Saturday, or use names; 7 is Sunday, the same as 0)
 # │ │ │ └────────── month (1 - 12)
 # │ │ └─────────────── day of month (1 - 31)
 # │ └──────────────────── hour (0 - 23)
 # └───────────────────────── min (0 - 59)

You can set the cron to be whatever time works for you, I just gave more example times than the original post did, in case you would like some ideas.

share|improve this answer
    
Thanks for the reply, I may do this. I was hoping someone had a suggestion using upstart or adjusting an existing script. It's just so strange Apache will respawn, but MySQL wont (as defaults). –  Shawn Khameneh Feb 21 at 21:12
    
@ShawnKhameneh This might be more reliable than upstart. I have seen quite a few threads about problems with upstart starting MySQL. But either way, glad to help. –  DevNull Feb 21 at 21:21
    
Interesting, I had some issues with upstart and Node respawns. Upstart wont respawn if the process has exit status 0. –  Shawn Khameneh Feb 21 at 21:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.