# 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:

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.
LVL 1
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
http://www.php.net/manual/en/features.commandline.php

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.
0
Author Commented:
does every commandline php file need a shebang line

what should the shebang be
0
Commented:
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.
0
Author Commented:
>>"launch"
how

>>"-f option"

what do i put in
two textboxes

program script:
0
Commented:
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:

http://msdn.microsoft.com/en-us/library/aa383614%28VS.85%29.aspx
0
Author Commented:
tried
"c:\path\to\php.exe" is the script/program, and "-f myfile.php" is the argument list.

and
"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
0
Author Commented:
when the php file is in the argument list I get

Event ID:      101
Level:         Error
Keywords:
User:          SYSTEM
Computer:      computer
Description:

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
0
Commented:
Let's see if I can clear this up for you.  Please see the code and images below.
<?
// contents of d:\test.php
$x=fopen("d:\stuff.txt","w+"); fwrite($x,print_r($argv,1)); fclose($x);

/*

D:\>type \stuff.txt
Array
(
[0] => d:\test.php
[1] => these
[2] => are
[3] => arguments
)
*/
?>

0
Author Commented:
i am using another php file

but it only runs for 43 seconds... before timing out
0
Commented:
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.
0

Experts Exchange Solution brought to you by