By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,963 Members | 1,778 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,963 IT Pros & Developers. It's quick & easy.

mysql cron job restart thingy

RedSon
Expert 5K+
P: 5,000
Hi guys,

I don't really know anything about cron jobs but I need something that will check to make sure my mysql server is up and running every few minutes or so. Or maybe one that can detect if the mysql process died and restart it. I also need to make sure that it is set to come on line after a reboot.

I'm running Ubuntu Feisty. Mysql Ver 14.12 Distrib 5.0.38.

Thanks!
Jun 15 '07 #1
Share this Question
Share on Google+
7 Replies


arne
Expert 100+
P: 315
Hi guys,

I don't really know anything about cron jobs but I need something that will check to make sure my mysql server is up and running every few minutes or so. Or maybe one that can detect if the mysql process died and restart it. I also need to make sure that it is set to come on line after a reboot.

I'm running Ubuntu Feisty. Mysql Ver 14.12 Distrib 5.0.38.

Thanks!
RedSon,

I don't really know anything about mysql :-), but I guess that there's an init script to start the server. Have a look in /etc/init.d/. These init scripts usually take the standard arguments (start, stop, restart and status). You could write a script, which is checking the status (/etc/init.d/mysqld status) and depending on the result start the daemon (/etc/init.d/mysqld start). For this script you could then make an crontab entry.

BTW, the init script is typically also used to start your service at boot time. Depending on the runlevel into which you're booting your system, the corresponding services are started.

HTH,
arne
Jun 15 '07 #2

RedSon
Expert 5K+
P: 5,000
RedSon,

I don't really know anything about mysql :-), but I guess that there's an init script to start the server. Have a look in /etc/init.d/. These init scripts usually take the standard arguments (start, stop, restart and status). You could write a script, which is checking the status (/etc/init.d/mysqld status) and depending on the result start the daemon (/etc/init.d/mysqld start). For this script you could then make an crontab entry.

BTW, the init script is typically also used to start your service at boot time. Depending on the runlevel into which you're booting your system, the corresponding services are started.

HTH,
arne
When mysql is not running I do that.

/etc/init.d/mysql restart

And everything runs fine. But I want something that automates that. I don't know how to do bash scripting or cron stuff, so if someone wouldn't mind giving me the simple form of the script or send me a link of something similar to tutor myself with I would appreciate it.

Gracias!!!
Jun 15 '07 #3

arne
Expert 100+
P: 315
When mysql is not running I do that.

/etc/init.d/mysql restart

And everything runs fine. But I want something that automates that. I don't know how to do bash scripting or cron stuff, so if someone wouldn't mind giving me the simple form of the script or send me a link of something similar to tutor myself with I would appreciate it.

Gracias!!!
An even simpler (and better) solution (no additional scripts, no cronjob) would be to create an entry in /etc/inittab. Try 'man inittab' and look for the 'respawn' option.

arne
Jun 16 '07 #4

RedSon
Expert 5K+
P: 5,000
An even simpler (and better) solution (no additional scripts, no cronjob) would be to create an entry in /etc/inittab. Try 'man inittab' and look for the 'respawn' option.

arne
there is no manual entry for inittab but I will look online to see what I can find. Thanks for the tip!
Jun 18 '07 #5

arne
Expert 100+
P: 315
there is no manual entry for inittab but I will look online to see what I can find. Thanks for the tip!
Yes, should be easy to find, here's one example: man inittab

arne
Jun 19 '07 #6

Motoma
Expert 2.5K+
P: 3,235
Hi guys,

I don't really know anything about cron jobs but I need something that will check to make sure my mysql server is up and running every few minutes or so. Or maybe one that can detect if the mysql process died and restart it. I also need to make sure that it is set to come on line after a reboot.

I'm running Ubuntu Feisty. Mysql Ver 14.12 Distrib 5.0.38.

Thanks!
Is MySQL just dying? I think the best solution would be to determine what is causing it to do so.
Jun 19 '07 #7

RedSon
Expert 5K+
P: 5,000
Turns out ubuntu uses a thing called upstart which is a bunch of scripts in etc/event.d. It is a pretty interesting replacement for inittab plus it is perfectly compatible with inittab scripts.
Jun 19 '07 #8

Post your reply

Sign in to post your reply or Sign up for a free account.