Home >Backend Development >PHP Tutorial >How to Execute a PHP File in a Scheduled Task on Windows?

How to Execute a PHP File in a Scheduled Task on Windows?

Patricia Arquette
Patricia ArquetteOriginal
2024-12-03 06:41:10823browse

How to Execute a PHP File in a Scheduled Task on Windows?

Running a PHP File in a Scheduled Task on Windows

Envision this scenario: you desire to create a scheduled task to execute a PHP script. You've diligently completed all the necessary settings, but to your dismay, the task stubbornly refuses to cooperate. It simply renders the PHP file in Notepad, leaving you perplexed.

The key to unlocking this enigma lies in crafting the correct "Run" command. Instead of directly invoking the PHP file, you must employ the syntax:

C:\Path\to\php.exe -f "C:\Path\to\file.php"

This command instructs the task scheduler to execute PHP with the -f option, which allows you to specify the PHP script to be executed.

For further clarity, you can reference the PHP command-line help for the -f option:

-f         Parse and execute <file>.

By adhering to this modified "Run" command, your scheduled task will now successfully execute the PHP script as intended, effectively automating your workflow.

The above is the detailed content of How to Execute a PHP File in a Scheduled Task on Windows?. For more information, please follow other related articles on the PHP Chinese website!

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