Windows: scheduled PHP execution and windowsphp. Windows: regular execution of PHP skills; windowsphp skills: regular execution of PHP in windows I believe many readers (PHP fans) often complain about the following during their work and study processes: windows PHP
In windows, regular PHP execution is believed by many readers (PHP fans) who often complain during their work and study: How does WIN allow PHP to send regular messages ?? How can I enable MYSQL to achieve automatic backup without any worries ?? If you rely entirely on manual work, you can also achieve it, but the operation seems too cumbersome! Don't worry, you can easily solve this problem by using the system Task Scheduler (Windows 98 is called a scheduled task. This feature is often ignored by many users or never imagined :).
The so-called task plan is to use a computer to automatically call the user's preset applications, so as to simplify user operations. We can schedule any script, program, or document to run at the most appropriate time using the Windows 2000 Task Scheduler (equivalent to the cron program under * NIX, which is not detailed here, to meet your needs. The following uses Windows 2000 as an example.
Specifically, if you need to use the Task Scheduler to run automatically, perform the following steps:
1. click Start, select "program"> "attachment"> "system tools"> "task Plan" (or "set"> "control panel"> "task Plan "), start the task scheduler management program for Windows 2000.
2. in the "Task Scheduler" window, double-click the "Add Task Scheduler" icon to start the "Task Scheduler wizard" of the system, and then click the "next" button, select the application to be automatically run in the program list, and click "next.
Set the appropriate task plan name and select the time frequency for automatic execution of the task (such as daily, weekly, monthly, one-time, every start of the computer, and every login time ), click "next.
At this time, the system will require the user to set the specific time for the program to run, such as the number, the number of minutes, and the time period to run. we only need to set the time according to our own needs.
4. the system will ask the user to set the appropriate user name and password so that the system can run automatically in the future.
5. finally, you only need to click the "finish" button to add the corresponding task to the task scheduler in Windows 2000. then it will automatically "remember" the task, once the system time and related conditions are consistent with the user's plan, it will automatically call the user's specified application, very convenient (every time Windows 2000 is started, the task scheduler will be automatically started and run in the background to ensure that your plans can be executed on time ).
Now let's test whether the task we just created is successful. right-click the "php" program icon (6) and select "run" in the pop-up menu ". In general, the program icon can be started as long as it is activated and running. If the operation fails, check whether the user and password are correctly set, and check whether the "Task Scheduler" service has been started. I turned it off to save system resources, causing the operation to fail, I have been searching for it for a long time. In addition, you can also view in the "system log" what caused the operation failure.
Now we have discussed the application of such a multi-task plan. here are two examples:
1. run PHP regularly!
1. edit the following code and save it as test. php:
$ Fp = @ fopen ("test.txt", "a + ");
Fwrite ($ fp, date ("Y-m-d H: I: s"). "Let PHP run regularly! \ N ");
Fclose ($ fp );
?>
Open the text input: D: \ php4 \ php.exe-q D: \ php4 \ test. php
Save as. bat format.
D: \ php4 \ php.exe is the php installation path, and D: \ php4 \ test. php is the path of the program to be periodically run.
2. add a task scheduler and select the. bat file.
3. set the time to run the task once every one minute and then run the task.
4. now let's see if the content in the d: \ php4 \ test.txt file is successful. If the content is as follows, congratulations.
11:08:01 let PHP run regularly!
11:09:02 let PHP run regularly!
11:10:01 let PHP run regularly!
11:11:02 let PHP run regularly!
II. make it possible for MYSQL to implement automatic backup!
1. edit the code below and save it as backup.php. if you want to compress the code, you can copy rar.exe:
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. http://www.dareng.com
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:
Can be database name you wowould like to backup.
With the -- help, or -? Options, you can get this help and exit.
} Else {
$ Dbname = $ argv [1];
$ Dump_tool = "c: \ mysql \ bin \ mysqldump ";
$ Rar_tool = "d :\\ php4 \ rar ";
@ Exec ("$ dump_tool -- opt-u user-ppassword $ dbname>./$ dbname. SQL ");
@ Exec ("$ rar_tool a-ag_yyyy_mm_dd_hh_mm mongodbname.rar $ dbname. SQL ");
@ Unlink ("$ dbname. SQL ");
Echo "Backup complete! ";
}
?>
2. add a task scheduler and enter the following command in step (2:
D: \ php4 \ php.exe-q D: \ php4 \ backup. php databasename
3. set the time to run the task once every day and then run the task.
4. an rarfile consisting of the database name and current time will be generated in the d: \ php4 \ directory.
5. Congratulations! Success!
Of course, there are many backup methods, so readers can do what they like!
1. if an error occurs:
An error occurred while trying to set the task account information.
The specified error is:
0x80070005: Access Denied
You do not have permission to run the requested operation
In the above '"4. next, the system will require the user to set the appropriate user name and password (5), so that the system can automatically run in the future ". it is best to use a "system" user. The password can be blank.
This system has a very high level of permissions, which is higher than your administrator, so you should never mess up when running the command, but if there is no prompt, it will be executed unconditionally, you can kill the core process with this permission.
When running PHP regularly on windows, I believe many readers (PHP fans) often complain about how to make PHP automatically on a regular basis in windows...