473,387 Members | 1,364 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

mysql cron job restart thingy

RedSon
5,000 Expert 4TB
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
7 4982
arne
315 Expert 100+
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
5,000 Expert 4TB
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
315 Expert 100+
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
5,000 Expert 4TB
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
315 Expert 100+
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
3,237 Expert 2GB
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
5,000 Expert 4TB
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

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

Similar topics

4
by: Neil | last post by:
Hi, I hope this question isn't too far off topic....I'm almost at my wits end trying to figure this out. I have a Mysql database and I wish to automate the backup of the database because I...
0
by: Mark Adams | last post by:
I am a relative newbie to MySQL. I had a Postfix+Courier+MySQL mail server running for several months. It took me a week or so to get it up and running in September. Now, I did a clean upgrade to...
3
by: the.natalie | last post by:
Hi. I am a newbie to mysql, cron, and shell scripting, so please bear with me. I have a script that is used for updating an image directory based on contents in a database. The script does the...
4
by: Richard | last post by:
Hi All, I've been trying to build a Ruby-on-Rails plus MySQL application. I'm running Ruby 1.8.2, Rails 1.1.4 and MySQL 5.0.15-nt over WinXP-Pro/SP2. I run under an Administrative account. ...
3
by: dburdick | last post by:
I was referred to this forum as this may be a php specific problem. Some kind of configuration problem maybe. I have some php files that connect to a mysql database and are run as cron jobs. ...
0
by: Pratchaya | last post by:
In my.cnf i add these lines ####### log-bin log-slow-queries = /var/log/mysqld-slow.log long_query_time=1 #######
4
by: martinf | last post by:
Hello group, I've inherited a box running FC6. The website I'm trying to copy across to it ran fine on FC5.. PHP & MySQL were set up 'out-the-box' so the site just worked. Somethings...
2
by: mezise | last post by:
Posted by Pratchaya: ------------------------------------------------------ MySQL Slow Log ERROR In my.cnf i add these lines ####### log-bin log-slow-queries = /var/log/mysqld-slow.log
1
by: symbioid | last post by:
Hello, I'm working on a project, and VMware has problems with suspending the virtual machine. We are accessing the machine through samba. However, when I suspend the VM, it stops the Samba...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.