开发者

Synchronising two mysql databases with a chron script

I have two mysql databases which I would like to sync every couple of hours, I'm aware that my ISP offers cron scripts for this purpose but have no experience with开发者_如何学运维 cron can anyone point me to a decent resource for learning cron - I haven't had much luck searching.


Here is a concise, printable and to the point text document that covers all the basics.

A simple example of what you may be looking to have in your crontab:

15 2 * * * /usr/bin/mysqldump –opt –all-databases -u root -pPASSWORD > /foo/bar/db-`date +%Y-%m-%d`.sql

That job, would run a backup task daily at 2:15 AM.

On a sidenote, if you just need this for regular backing up purposes and not actual duplication, I have come to love this script for quick and dirty db backups.

Good-luck.


cron is a mechanism for executing a script (or executable) at a regular time. The script can be written in any script language, so pick one you are familiar with. Shell script (e.g. bash) is often used, but you could use perl, python, PHP etc.

The wikipedia page has information about the cron format for specifying when the script will run: http://en.wikipedia.org/wiki/Cron

Your ISP may provide easy access via a control panel, or you may have to request them to setup the cron job. You'll need to find out from them exactly how to set it up.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜