2

Does anyone have a simple solution for scheduling PHP tasks running in IIS?

I have a php script which backs up our databases and emails to our backup address on a separate server.

I have admin access to the server. Thanks!

Chris
  • 2,340
  • 6
  • 40
  • 63
  • I'm not aware of a scheduling function in IIS, but what about Windows's task planner? – Pekka Mar 08 '11 at 11:03
  • hmm maybe this should be posted on server fault group? im not sure :-s – Chris Mar 08 '11 at 11:03
  • ah windows task planner sounds good, but I cant exactly have it load internet explorer, it would leave multiple windows open? – Chris Mar 08 '11 at 11:04

1 Answers1

4

Assuming that you can run PHP from the command line, just set these jobs using the Windows Task Scheduler, they can be configured from Control Panel/Scheduled Tasks.

A typical task might look something like:

C:\PHP\php.exe -f BOINCStats.php

with the "Start in" directory set as

C:\PHP

You can find full details for running PHP from the command line in the manual

EDIT

If you create a .bat file, you might like to ensure that it references a specific php.ini

e.g.

C:\xampp\php\php -c \xampp\php\php5CLI.ini %1 %2 %3 %4 %5 %6 %7 %8 %9
NullUserException
  • 83,810
  • 28
  • 209
  • 234
Mark Baker
  • 209,507
  • 32
  • 346
  • 385
  • Did you mean php.exe? I can't see php.bat – Chris Mar 08 '11 at 11:07
  • So I create a batch file with this .. C:\PHP5\php.exe -f "C:\PHP Scripts\script.php" – Chris Mar 08 '11 at 11:10
  • I will accept this answer, but I have to wait 7 minutes first. – Chris Mar 08 '11 at 11:10
  • I have changed this to php.exe... I actually have a bat file that sets a few configuration switches common to all the files I run from the scheduler, and I just cut-and-pasted that example tasks from an actual scheduled PHP task; but you could just as easily call the php.exe directly – Mark Baker Mar 08 '11 at 11:11
  • Got it all setup for daily backups. Tested the scheduled task and boom emails with my database backups came through. Many thanks :) – Chris Mar 08 '11 at 11:50