SitePoint Sponsor

User Tag List

Results 1 to 9 of 9

Hybrid View

  1. #1
    SitePoint Guru Dashman's Avatar
    Join Date
    Jan 2006
    Location
    Manchester, UK
    Posts
    627
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Run a PHP script from withn windows without opening a browser

    Hi guys ...

    We currently have WAMP set up on, well, a local Windows machine. On this server, there is a script that checks a MySQL DB for records that match certain criteria, and then transfers these records from the local machine to a remote server.

    The script is working as it should, but can obviously only be executed when opened in a browser via http://localhost/myscript.php ...

    We need to schedule this script to run every half an hour. From research, it seems easy enough to schedule a browser to open and run the script via Windows' Scheduled Tasks.

    The problem is, that this local machine is being used at an interactive installation, and we therefore do want a browser opening every half an hour...

    What is the best (or ANY) way to get the PHP script to execute without any browser/command window etc opening?

    D

  2. #2
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could run it as a CRON job.
    CRON for windows

  3. #3
    SitePoint Guru Dashman's Avatar
    Join Date
    Jan 2006
    Location
    Manchester, UK
    Posts
    627
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi thanks for that. So, just before I try install etc on the Windows machine, it wont open any Windows etc when it runs?

    D

  4. #4
    . 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 should run though the command hidden under windows but remember to set the path to PHP.

    http://www.sitepoint.com/forums/show...87&postcount=2
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    SitePoint Guru Dashman's Avatar
    Join Date
    Jan 2006
    Location
    Manchester, UK
    Posts
    627
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers,

    Now, reading the docs for CRONW, we will need to install PERL to install CronW?

  6. #6
    Sell crazy someplace else markl999's Avatar
    Join Date
    Aug 2003
    Location
    Manchester, UK
    Posts
    4,007
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dashman View Post
    Cheers,

    Now, reading the docs for CRONW, we will need to install PERL to install CronW?
    Yeah, it requires Perl, ActiveState's distribution is recommended.

  7. #7
    SitePoint Zealot
    Join Date
    Mar 2007
    Posts
    192
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use windows task scheduler

    there should be an executable called php.exe that you can run with the script name as a parameter. cron is for linux based machines, and windows does have an equivalent.

  8. #8
    SitePoint Zealot
    Join Date
    Mar 2007
    Posts
    192
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    why are you using a thirdparty software to do this? windows has a task scheduler.. is there something wrong with windows task scheduler that requires one to go and install perl so that they can run a program to do the same thing?

    tutorial on setting up a task and setting advanced options: http://www.iopus.com/guides/winscheduler.htm
    Last edited by voodoomagic; May 1, 2007 at 10:27. Reason: adding link

  9. #9
    SitePoint Guru Dashman's Avatar
    Join Date
    Jan 2006
    Location
    Manchester, UK
    Posts
    627
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    We are kind of leaning towards using the scheduler, but encountered various upload errors (the script also uploads files to the remote server) that we do not encounter when running the script in a regular fashion via the browser...

    This test was done by calling the script from the command line, with all environment variables set correctly.

    Using the task scheduler, should we still be able to access the databases and create remote connections as well as perform these uploads etc?

    D


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
  •