Job scheduler to run every day
I want to make a backup of a Mysql database or table every day. So I would like to write a scheduler which will run automatically every day at that particular time.
Can someone please provide开发者_StackOverflow社区 the code of how this can be done?
If you're on a Unix/Linux/BSD server, you want to read about cronjobs. If it's a Windows server, you want to read about scheduled tasks. This way, you can have a piece of code be executed every day. I would suggest not doing this with PHP, as mysqldump is much more reliable.
http://www.noupe.com/how-tos/10-ways-to-automatically-manually-backup-mysql-database.html
Something like this on a unix based system would work. For more info see some cron documentation and mysql documentation
0 0 * * * /usr/bin/mysqldump -u dbusername dbname -p password > /home/uesrname/backup.sql
If you're on Windows get the MySQL GUI tools. It has a backup scheduler http://dev.mysql.com/downloads/gui-tools/5.0.html
Have a look at CRON jobs. Google will be a good start.
精彩评论