How to Run a PHP File in a Scheduled Task (Windows Task Scheduler)

How do I run a PHP script using windows schedule task?

Locate the php.exe executable on your system and pass it the name of the script file using the -f parameter.

Example:

C:\Xampp\php\php.exe -f C:\Xampp\htdocs\my_script.php

Reference:

  • Introduction to using PHP on the command line
  • PHP command line options

Run PHP script with Windows Task Scheduler, including files fails

this should work:

cd /D "D:\xampp\htdocs\MyApp\App\Cronjobs\"
"D:\xampp\php\php.exe" -f CronjobBase.php MyCronJob

OR:

D:
cd "D:\xampp\htdocs\MyApp\App\Cronjobs\"
"D:\xampp\php\php.exe" -f CronjobBase.php MyCronJob

PHP script in windows task scheduler

I solve it by running my PHP script through batch file.

and scheduling the batch file in Windows task scheduler.

this post helped me so much:

http://www.devside.net/wamp-server/running-php-scripts-as-cron-jobs-on-windows

Creating A Scheduled Task on PHP Running Under IIS

You could use Task Scheduler on the server to run a batch file that runs the PHP script via command line at a regular interval, which i hope should solve your problem.



Related Topics



Leave a reply



Submit