How to run a PHP file in a scheduled task (Windows Task Scheduler)

How to create a scheduled task to run a PHP file?
Yes, I filled in everything in the scheduled task, but it still does not work.

Launch: "C: \ Program Files \ Apache Software Foundation \ Apache2.2 \ htdocs \ WEB \ 4w_website \ save.php"

Getting started: "C: \ Program Files \ Apache Software Foundation \ Apache2.2 \ htdocs \ WEB \ 4w_website"

It simply opens the PHP file in Notepad.

I gave the correct username and pwd.

Please help me..

+44
windows php scheduled-tasks
Nov 17 '08 at 11:45
source share
7 answers

Run command should be

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

At the php.exe help command line:

 -f Parse and execute <file>.
+66
Nov 17 '08 at 12:00
source share
β€” -

I wrote a .bat file that does the work of file.bat

 @ECHO OFF php.exe -f "C:\code\cust.php" 

And put it in the Schedule Tasks, for example:

Run: C:\code\file.bat

Start with: C:\code\

+14
Feb 03 2018-12-12T00:
source share

If you use php scripts, in most cases the script is waiting for execution in the current folder. This means that you must configure the folder for each of your actions, use the " Start at " field.

Example:

 Run: C:\php\php.exe Arguments: -f C:\web\myscript.php 

Do not forget:

  Start in: C:\web\ 
+6
Jan 28 '14 at 10:05
source share

It looks like you have no exe related PHP files.

You can do this My Computer > Tools > Folder Options > File Types . If nothing else, it can also help you check your settings for them.

Otherwise, you can specify "C: \ path \ to \ php.exe [file]" in the task.

+5
Nov 17 '08 at 11:53
source share

This is what I did:

  • Php file

     <?php my code goes here ?> 

    * Please note that if you use the HTTP API / CURL in the CLI, use dl("php_curl.dll");

    this loads curl in cli

  • Now I have added PHP to the variable path to Windows, this can be done using my computer, properties, additional parameters, environment variables, new

  • Then I created a .bat file, just open notepad and enter the code below and save as myfile.bat

     @ECHO OFF php -fd:\wamp\www\V3\task.php 

    This site can help you with the syntax of the .bat file.

  • Now create a new scheduled task on Windows and call the above .bat file as a source,

+2
Jul 03 '12 at 5:14
source share

For those people who cannot complete @Tomalak answers:

Check if there are spaces in your directory ( ) If so, you need to attach them to. "

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

And if it still does not work, check file.php if there are files in it.

 include("file2.php"); /* OR */ include_once("file2.php"); 

Remove it. And if the required file in your file.php really needed, try moving the / script code from the included file to your main file.

+2
Oct 07 '15 at 0:52
source share

I think you should execute your PHP script via URL. you can write a batch script for the execution url. Why don't you write the backend script in another language like batch script, vbscript etc.

-2
Nov 17 '08 at 11:50
source share



All Articles