Running PHP from background

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ddtpmyra
    Contributor
    • Jun 2008
    • 333

    Running PHP from background

    Hello,

    I want to create a program that has auto email capability everytime my query is satisfied and the email alert will be send daily at 8am for instance. How can I do that? should I run it using the batch file calling the PHP script? Anobody who did this kind of functionality?

    thanks,
    DM
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, DM.

    I take it you're running a Windows server?

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      If you're on Windows, you can use Windows Scheduled Tasks.

      Configuring cron jobs on Windows | drupal.org

      Comment

      • ddtpmyra
        Contributor
        • Jun 2008
        • 333

        #4
        Im running it on Windows and when I do that it automaticall open my dreamweaver as my editor. Please advice

        Comment

        • Canabeez
          New Member
          • Jul 2009
          • 126

          #5
          Originally posted by ddtpmyra
          Im running it on Windows and when I do that it automaticall open my dreamweaver as my editor. Please advice
          Let me guess, you've put your *.php file into the crontab?

          Comment

          • Markus
            Recognized Expert Expert
            • Jun 2007
            • 6092

            #6
            well, you need to specify which program will be used to run the script. If you do not, the default program for opening the file type will be used - in your case, Dreamweaver.

            Should look something like this (assuming you have php.exe in your PATH):

            Code:
            php /path/to/file.php

            Comment

            • ddtpmyra
              Contributor
              • Jun 2008
              • 333

              #7
              I put it the .php file where the PHP.exe is located but still it opens my dreamweaver. Can you tell me how to do this correctly?


              Originally posted by Markus
              well, you need to specify which program will be used to run the script. If you do not, the default program for opening the file type will be used - in your case, Dreamweaver.

              Should look something like this (assuming you have php.exe in your PATH):

              Code:
              php /path/to/file.php

              Comment

              • dlite922
                Recognized Expert Top Contributor
                • Dec 2007
                • 1586

                #8
                PHP is a program. It's literally called php.exe... This is in some folder (directory) on your hard drive: either use the command line to go to that directory, or put that directory in your PATH variable (see Google), so that Windows can know where to look for that program when you TYPE php on the command line. Once you done that:

                A good test is to type php -v on a command line and it should give you the php version number, if it says it can't be found, php is not installed, not in the directory, or it's not your PATH variable.

                If it does work, good. now type this:

                php -q -f C:/path/to/your/php/file.php

                It should execute your php program. Put this in a BATCH file (again, Google it) and then add a scheduled task:

                Windows:
                Start > Programs -> Accessories -> System Tools -> Scheduled Tasks

                Add new task, Browse to where you saved this batch file.

                configure the frequency and time it will run.

                Your Done!


                Dan

                Comment

                Working...