Home  >  Article  >  Backend Development  >  How to implement PHP scheduled code execution under windows server_PHP tutorial

How to implement PHP scheduled code execution under windows server_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:10:591161browse

This article will introduce how to implement any plan in Windows and PHP. Students in need can refer to it.

1. Let PHP run regularly!
1. Edit the following code and save it as test.php:

The code is as follows
 代码如下 复制代码
$fp = @fopen("test.txt", "a+");
fwrite($fp, date("Y-m-d H:i:s") . " 让PHP定时运行吧!n");
fclose($fp);
?>
Copy code


$fp = @fopen("test.txt", "a+");

fwrite($ fp, date("Y-m-d H:i:s") . " Let PHP run regularly! n");

fclose($fp);

?>

Open text input: D:php4php.exe -q D:php4test.php
Save in .bat format.
D:php4php.exe is the php installation path, and D:php4test.php is the path of the program to be run regularly.

2. Add a task plan, select the .bat file


3. Set the time to run every 1 minute, and then run the task.

 代码如下 复制代码

if ($argc != 2 || in_array($argv[1], array('--help', '-?'))) {
?>
backup   Ver 0.01, for Win95/Win98/WinNT/Win2000/WinXP on i32
Copyright (C) 2000 ptker All rights reserved. This is free software,and you are welcome to modify and redistribute it
under the GPL license

PHP Shell script for the backup MySQL database.

Usage:

  

4. Now let’s see if the content of the d:php4test.txt file was successful. If the content is as shown below, congratulations on your success.


2003-03-03 11:08:01 Let PHP run regularly!
2003-03-03 11:09:02 Let PHP run regularly!
2003-03-03 11:10:01 Let PHP run regularly!
2003-03-03 11:11:02 Let PHP run regularly!

2. Make automatic backup possible for MYSQL!

1. Edit the following code and save it as backup.php. If you want to compress it, you can copy a rar.exe:

Usage:
The code is as follows

Copy code


if ($argc != 2 || in_array ($argv[1], array('--help', '-?'))) {
?>
backup Ver 0.01, for Win95/Win98/WinNT/Win2000/WinXP on i32Copyright (C) 2000 ptker All rights reserved. This is free software, and you are welcome to modify and redistribute it

under the GPL license

PHP Shell script for the backup MySQL database.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn