Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Jan 2003
    Location
    Tulsa, OK
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Scheduled Task > Batch File > PHP Script

    I'm trying to run a PHP script through a Windows scheduled task. I set up a batch file reading:
    Code:
    c:\php\php.exe cron.php
    'cron.php' being the script I want to run in the task.

    The script works in a browser but gives me errors when I see it run in the console. All the script does is connect to a database delete some records from temp databases and writes a log file. The log files write but it never connects to the database. It yells 'Unable to connect to XXX.XXX.XXX.XXX on line XX. Why would it work in the browser, but not the batch file?

    Yes?

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    do you have mysql (assuming you are using mysql) running when the task is run?
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    chmod file list

    explain countries & tables

    does your script rely on any server variables , eg $_SERVER['PHP_SELF'] , $_SERVER['DOCUMENT_ROOT'] etc ?
    or $_GET or $_POST data ?? remember these are not always available in the CGI binary
    (some $_SERVER variables are in the cli binary though I think)

    if you want to pass any variables to the script use $argc & $argv variables
    .. /path/to/script.php arg1 arg2 arg3
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #4
    New Coder
    Join Date
    Jan 2003
    Location
    Tulsa, OK
    Posts
    69
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Its MSSQL and no I don't pass any arguments to the script. It's all runs internally.


  •  

    Posting Permissions

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