Note: the "Task Scheduler" that Windows comes with must be seen in this tutorial first.
First, create a bat suffix file. My is Timerexecutephp.bat file
Timerexecutephp.bat This file is used to execute the specified PHP file periodically
Timerexecutephp.bat File Contents:
F:\web\php-5.6.22-Win32-VC11-x64\php.exe F:\web\htdocs\demo\timer.php
Comments:
1. F:\web\php-5.6.22-Win32-VC11-x64\php.exe is the Php.exe file path under the PHP installation directory
2, F:\web\htdocs\demo\timer.php to execute the PHP file
Then is the PHP file to execute such as: timer.php
<?PHP/*regularly back up database files*///Setting the time zoneDate_default_timezone_set (' PRC ' );//generate file names based on time$bakFileName=Date(' Ymdhis ', Time() ) . '. SQL ';$command= "F:/web/mysql-5.6.31-winx64/bin/mysqldump-u Root-pabner Dede >f:/test\\{$bakFileName}";/** * f:/web/mysql-5.6.31-winx64/bin/mysqldump mysql installed directory mysqldump file path * Root Database account * Abner Database Password * Dede to back up the database name * f:/ test\\{$bakFileName} Generate backup File * *-------------------EXEC () function usage------------------------------------* EXEC syntax: string EXEC (String command, string [array], int [return_var]); * Exec return Value: String * command– command to execute * array– is output value * return_var– is the return value 0 or 1, if return 0 succeeds, return 1 execution fails*/exec($command,$arr,$num);if($num= = 0) Echo"OK";Else Echo"No";?>
Scheduled backup of MySQL database under Windows.