Home >Backend Development >PHP Tutorial >Windows executes PHP files regularly
PHP develops related system programs mainly to facilitate work and management. Timing tasks can implement regular execution, and PHP logic can implement what to do each time it is executed. The two combined can greatly reduce the time and cost of manual intervention. For example, delete logs regularly, back up the database regularly, etc.
1. Write a PHP program and name it cron.php.
2. Create a new Bat file and name it test.bat
The content is as follows:
D:\php\php.exe -q D:\website\cron.php
It should be noted that: php The directory location of the .exe and the location of the cron.php file.
3. Create a WINDOWS scheduled task:
Start->Control Panel->Task Schedule->Add Task Schedule
Browse files Select the test.bat file above
Set the time and password (for logging in to WINDOWS)
Save it.
4. Right-click the scheduled task and click "Run"
For more PHP related knowledge, please visit PHP Chinese website!
The above is the detailed content of Windows executes PHP files regularly. For more information, please follow other related articles on the PHP Chinese website!