Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

How can I create a scheduled task to run a PHP file?
Yes, I filled out everything in the scheduled task, but it still doesn't work.

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

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

It just opens the PHP file in Notepad.

I gave the correct user name and pwd.

Please help me..

like image 363
praveenjayapal Avatar asked Nov 17 '08 11:11

praveenjayapal


People also ask

How do I trigger a php file?

Step 1: First of all, open the Apache Friends website and download XAMPP for Windows, and install it. Step 2: Start the XAMPP Program Control Panel. Click on the “Start” button next to the “Apache” to start your Apache Web Server. Also, start “MySQL” if your PHP programs depend on a MySQL database to run.


2 Answers

The Run command should be

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

From the command line help of php.exe:

 -f         Parse and execute <file>. 
like image 54
Tomalak Avatar answered Oct 02 '22 12:10

Tomalak


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

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

And put it in the Schedule Tasks like this:

Run: C:\code\file.bat

Start in: C:\code\

like image 39
matobago Avatar answered Oct 02 '22 11:10

matobago