Run PHP file as cronjob

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mossum

    Run PHP file as cronjob

    Hello,

    I have a PHP file that reads another PHP file and writes it as a static
    HTML page. I'd like to run the first PHP file as a cronjob (so that the
    static HTML page is updated once an hour).

    I'm familiar with scheduling a cronjob and all the PHP is working
    perfectly. I don't know how to get cron to "run" a PHP file however.
    Any advice would be greatly appreciated.

  • Tommy Gildseth

    #2
    Re: Run PHP file as cronjob

    Mossum wrote:[color=blue]
    > Hello,
    >
    > I have a PHP file that reads another PHP file and writes it as a static
    > HTML page. I'd like to run the first PHP file as a cronjob (so that the
    > static HTML page is updated once an hour).
    >
    > I'm familiar with scheduling a cronjob and all the PHP is working
    > perfectly. I don't know how to get cron to "run" a PHP file however.
    > Any advice would be greatly appreciated.
    >[/color]

    Alt 1:
    If you have the CLI version of PHP installed, simply write
    @hourly /path/to/php/interpreter/php /path/to/php/script.php

    Alt 2:
    Use wget/lynx/curl etc etc to fetch the file via the webserver. You can
    then either echo the content out, and have wget/...etc save it to
    wherever you want it, or you can still do this in the PHP-script, and
    don't return any content to wget

    --
    Tommy Gildseth

    Comment

    • Mossum

      #3
      Re: Run PHP file as cronjob


      Tommy,

      Thank you! I tried scheduling a cron job with fetch -- and it works.

      Comment

      • Mladen Gogala

        #4
        Re: Run PHP file as cronjob

        On Wed, 21 Jun 2006 12:51:08 -0700, Mossum wrote:
        [color=blue]
        > I'm familiar with scheduling a cronjob and all the PHP is working
        > perfectly. I don't know how to get cron to "run" a PHP file however.
        > Any advice would be greatly appreciated.[/color]

        Beginning it with
        #!/usr/bin/php or #!/usr/local/bin/php would be a good start. Also,
        change protection to 755, so that httpd process can open it.

        --


        Comment

        Working...