473,903 Members | 3,324 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mysql cron job restart thingy

RedSon
5,000 Recognized Expert Expert
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 5018
arne
315 Recognized Expert Contributor
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 Recognized Expert Expert
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 Recognized Expert Contributor
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 Recognized Expert Expert
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 Recognized Expert Contributor
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 Recognized Expert Specialist
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 Recognized Expert Expert
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
4431
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 don't wish to rely on the web host doing so. I am using the "dbsender.php" script, which is written for this exact purpose (available at hotscripts.com). If I execute the script via my browser, the database is emailed to me in a 'gzip' format, which...
0
2844
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 Mandrake 9.2 and am reinstalling everything. This thing is kicking my ass and I can't seem to get past it. I could really use some help if anybody has any. Just for reference, this was my primary source for information on installation and...
3
10319
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 following: runs several queries against different tables in a database; returns several lists of pictures being used in the database; removes any obsolete images from specific directories. The script is bash shell script. The problem is that...
4
5376
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. I tried building the first example from Agile Web Development with Rails, 1st ed. Somehow the DB got corrupted and I couldn't recover. Instead of retrying that, I tried building the first example from Ruby For Rails, which worked fine.
3
2588
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. The scripts work fine when run via the command line as root, but when run via the cron they cause a mysql connection error. Call to undefined function: mysql_pconnect()
0
4452
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
2629
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 changed with FC6. Trying to run the DB script now gives:
2
10933
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
2715
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 service. The solution we hit upon was to run a script that checks, say, once a minute to determine whether the machine was active or suspended. If it's been longer than a minute, we restart the samba service.
0
9845
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11279
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10872
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10499
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9675
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8047
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4725
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4307
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.