Sunday 14 July 2013

How to schedule a PHP script in task scheduler

Quiet often there is a need to execute/run php script on some time interval at server side. And that php scripts should run automatically on windows server. You can add a task in windows task scheduler to run PHP script. 

PHP script can be executed easily on command prompt using the below command:
ex. C:\Path\to\php.exe -f "C:\Path\to\file.php"    
where -f is file attribute - parse and execute file.


Follow the below given steps to configure the PHP script to run in task scheduler.

1. To open task scheduler, click on Start >> Administrative Tools >> Task Scheduler.

2.Click on "create task" from "Actions" menu bar on right pane.




















3. In General tab, enter the name of the task.

4. In triggers tab, click on New and schedule the time at which script should execute, as per your requirements.




5.In Action tab, click on new and select 'Start a program' from Action option.Enter the path of PHP.exe in program/script field. Now enter the file option ex: -f c:\pathToHtdocs\fileName.php in Add Arguments field and click on Ok.



6. In condition tab, it is recommended all the option to default.




7. In settings tab, you can configure the options as per your requirements.


8. You are done with scheduling the PHP script, now you can select 'Run' option from options menu, to execute the task.

3 comments:

  1. Thank s for sharing a blog for PHP script in task scheduler. If you want to learn about features of asp hosting reviews
    then you can touch on that. You can also visit: www.mywindowshosting.com

    ReplyDelete
  2. Thank you for sharing this valuable tutorial. Keep on sharing. If you require asp.net and PHP hosting, please visit our site at http://www.hostforlife.eu

    ReplyDelete
  3. Nice tutorial....Helping me a lot to work out on it...Thank you for this ..I am waiting for your next tutorial...

    ReplyDelete