SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2011
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Windows tasks do not invoke includes when they run a php page?

    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?

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    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 ....

  3. #3
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    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...
    sptask.png

    "Start in" is like "CD some/path" in the command line.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  4. #4
    SitePoint Zealot
    Join Date
    Nov 2011
    Posts
    190
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  5. #5
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Use __DIR__ (PHP 5.3+) or direname(__FILE__) to get paths relative to the location of your file.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •