shinve — 2012-02-02T01:55:34-05:00 — #1
I do most of my development work in windows so I emulate cron jobs with windows task scheduler. But when I run a task it does not successfully include the includes in the php file, so I can't use my database connection includes. I have been building the necessary includes into the scripts but that is pretty annoying and time consuming.
task scheduler is set to run a .bat file named scheduled-task.bat which contains:
"cmd /K C:\wamp\bin\php\php5.3.8\php.exe -f C:\wamp\www\site\cron.php" (no quotes)
Any idea on how to fix this so my included files are actually included?
cups — 2012-02-02T02:21:07-05:00 — #2
I understand that PHP cli uses a different php.ini -- though how that works on win32 I am not sure.
Why dont you output phpinfo() from one of these scripts, pick up the output and check what it says for a) the include_path b) the ini file address.
Failing that, try and put a test include in the same folder and see if that gets get picked up ....
logic_earth — 2012-02-02T03:50:36-05:00 — #3
It has nothing to do with Task Schedular. Its probably as simple as "PATH NOT FOUND" for you includes. Understand, command line has completely different pathing then a server. Unless you are careful using full absolute paths are set the current worrking directory, paths will be different.
You could drop the batch file and let Task Scheduler direct access...
"Start in" is like "CD some/path" in the command line.
shinve — 2012-02-04T21:16:10-05:00 — #4
You were right; I didn't specify an absolute path. I tried writing an includes using an absolute path and it worked.Thanks. This may make emulation of a cron job a bit harder though, I think, since the includes on my dev machine and the includes on the server will be different, and I will have to replace them.
logic_earth — 2012-02-05T07:35:51-05:00 — #5
Use DIR (PHP 5.3+) or direname(FILE) to get paths relative to the location of your file.