Anyway to run PHP script using cronjob?

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

    Anyway to run PHP script using cronjob?

    Anyone know if I can run PHP script at command line?

    Thanks in advance!!
    -Steven


  • Stephen Jennings

    #2
    Re: Anyway to run PHP script using cronjob?

    On Mon, 21 Jul 2003 05:49:28 GMT, Steven <xueming@comcas t.net> wrote:
    [color=blue]
    > Anyone know if I can run PHP script at command line?
    >
    > Thanks in advance!!
    > -Steven
    >[/color]

    You can write shell scripts using the PHP interpreter. At the top of a
    file, write:

    #!/usr/bin/php

    Or whatever the path to PHP is. It may be /usr/local/bin/php, depending on
    which Unix you're using. Then you can just make the file executable and
    stick it in your crontab.


    Comment

    • Peter Peltonen

      #3
      Re: Anyway to run PHP script using cronjob?

      Stephen Jennings <nobody@example .com> wrote:[color=blue]
      > You can write shell scripts using the PHP interpreter. At the top of a
      > file, write:[/color]
      [color=blue]
      > #!/usr/bin/php[/color]
      [color=blue]
      > Or whatever the path to PHP is. It may be /usr/local/bin/php, depending on
      > which Unix you're using. Then you can just make the file executable and
      > stick it in your crontab.[/color]

      PHP 4.3.0 supports now the new CLI SAPI for running php from command line.

      Is it wort of upgrading from 4.1.2 just because of it? I'm running
      Red Hat Linux 7.3 and it would mean that I'd had to package PHP myself
      which would be a lot of work (and otherwise I've still been content
      with the old version).

      Regards,
      Peter

      Comment

      • Louis-Philippe Huberdeau

        #4
        Re: Anyway to run PHP script using cronjob?

        You can execute as a HTTP request too:

        lynx --dump http://localhost/page.php

        That way, it can even be done remotely. Don't forget the --dump,
        otherwise you will have a lynx process running each time that won't be
        killed.

        Stephen Jennings wrote:[color=blue]
        > On Mon, 21 Jul 2003 05:49:28 GMT, Steven <xueming@comcas t.net> wrote:
        >[color=green]
        >> Anyone know if I can run PHP script at command line?
        >>
        >> Thanks in advance!!
        >> -Steven
        >>[/color]
        >
        > You can write shell scripts using the PHP interpreter. At the top of a
        > file, write:
        >
        > #!/usr/bin/php
        >
        > Or whatever the path to PHP is. It may be /usr/local/bin/php, depending
        > on which Unix you're using. Then you can just make the file executable
        > and stick it in your crontab.
        >
        >[/color]

        Comment

        Working...