mysql cronjob

[xtm]

Verified User
Joined
Feb 1, 2006
Messages
16
Hi there.

ive had a quick search around but unable to locate anythin regarding this..

How would i add the command to restart the mysql every hour? Reason for this being the my sql crashes when the server load becomes high and its a nightmare to restart it without submiting a ticket to my host to reboot the server, Or i there is a guide to adding cronjobs that would be helpful

Thanks,
 
The command you'd use is dependent on your OS distribution.

For RedHat based distributions such as Red Hat Linux, Red Hat Enterprise Linux, White Box Linux, and CentOS, it would be:

service mysqld restart

but you should do it in a script because otherwise you won't know if MySQL actually restarted or not; sometimes it returns an error because it times out before it can shut down all the processes.

As far as actually setting up the cronjob, you can look at man 5 crontab should give you the information you need.

It'll need to run as root, and you can just drop the script into /etc/cron.hourly if you want.

Jeff
 
Back
Top