• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1091
  • Last Modified:

task scheduler php using windows server 2008

has anyone personally using windows server 2008 task scheduler to run a php5 file

if so how is it done

what do i put in
two textboxes

program script:
add arguments (optional):

i tried putting c:\php.exe and c:\file.php in both text boxes,  alternating both

I also tried using www.website.com/file.php

Nothing works

History will say that the file has been 'run'  but simple php does not run

My example php file is prints to a text file.
This file works.
With task scheduler file.php does not print to a text file.
  • 6
  • 5
1 Solution
Steve BinkCommented:

Running from the command line (which is essentially what Task Scheduler will do) is different from calling it on a website.  It is different not only in the calling semantics, but in the environment created.  Read through that manual section for a more thorough description of the differences, and come back with any remaining questions.
rgb192Author Commented:
does every commandline php file need a shebang line

what should the shebang be
Steve BinkCommented:
The shebang line is only for Linux installations.  Windows uses file associations to do approximately the same thing.  You will need to launch php.exe and use -f option to specify the file to execute.  
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

rgb192Author Commented:

>>"-f option"

what do i put in
two textboxes

program script:
add arguments (optional):
Steve BinkCommented:
That really depends on what you want it to do.  In its simplest form, the command line would be:

c:\path\to\php.exe -f myfile.php

In that case, "c:\path\to\php.exe" is the script/program, and "-f myfile.php" is the argument list.  I'm not sure you need to separate the two, though.  To my recollection, I've always used the full line in the script box, with the appropriate care taken for quoting path/filenames with spaces.

It sounds like you need to learn a little more about task scheduler.  I find the interface very intuitive and slightly less difficult than walking, even with the four or five tabs of information to look at.  See these links for more information:

rgb192Author Commented:
"c:\path\to\php.exe" is the script/program, and "-f myfile.php" is the argument list.  

"c:\path\to\php.exe" is the script/program, and "myfile.php" is the argument list.  

where myfile.php is in the same folder as php.exe

I also tried local location c: for php file and http location
rgb192Author Commented:
when the php file is in the argument list I get

Log Name:      Microsoft-Windows-TaskScheduler/Operational
Source:        Microsoft-Windows-TaskScheduler
Event ID:      101
Task Category: Task Start Failed
Level:         Error
User:          SYSTEM
Computer:      computer
Task Scheduler failed to start "\task" task for user "user". Additional Data: Error Value: 2147750687.

when php file is in script program, I do not get a task scheduler error, file.php does not run

this is why I have to use a .cmd or .bat file
Steve BinkCommented:
Let's see if I can clear this up for you.  Please see the code and images below.
// contents of d:\test.php

After the task runs:

D:\>type \stuff.txt
    [0] => d:\test.php
    [1] => these
    [2] => are
    [3] => arguments

Open in new window

rgb192Author Commented:
i am using another php file

your task scheduler setup made my php file run... thanks

but it only runs for 43 seconds... before timing out
Steve BinkCommented:
That is a separate question troubleshooting the script itself.  Task Scheduler is not responsible for what the task is doing, only for firing it off.  You will need to troubleshoot the script for why it hits the timeout.  I would start with max_execution_time, and some trace code designed to track the progress of the script and the time it takes to execute.
rgb192Author Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now