how to run a script automatically?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Yang Li Ke

    how to run a script automatically?

    Hi there,

    I have a php script which creates a .html
    gallery with thumbs and links etc..

    I would like it to update the gallery
    and change the thumbs according to some
    random values every 60 minutes

    Anyone can suggest me a way to do that?

    Thx

    Yang





    --


    -------------------------------------------------------------------------
    FIGHT BACK AGAINST SPAM!
    Download Spam Inspector, the Award Winning Anti-Spam Filter




  • Daniel Koñczyk

    #2
    Re: how to run a script automatically?

    Yang Li Ke <yanglike@sympa tico.ca> wrote:[color=blue]
    > Hi there,
    >
    > I have a php script which creates a .html
    > gallery with thumbs and links etc..
    >
    > I would like it to update the gallery
    > and change the thumbs according to some
    > random values every 60 minutes
    >
    > Anyone can suggest me a way to do that?[/color]

    I would suggest using cron/contab if you got access to it.
    It will run your update script every chosen period of time

    --
    Daniel Koñczyk
    Daniel Kończyk to niezależny programista specjalizujący się w tworzeniu aplikacji internetowych dostosowanych do potrzeb klienta, bazach danych, testowaniu i optymalizacji.

    Comment

    • Rob @ Home

      #3
      Re: how to run a script automatically?

      I'll try that...

      "Daniel Koñczyk" <drmartens@voru ta.eu.0rg> wrote in message
      news:slrnblsjnu .74q.drmartens@ gnu.univ.gda.pl ...[color=blue]
      > Yang Li Ke <yanglike@sympa tico.ca> wrote:[color=green]
      > > Hi there,
      > >
      > > I have a php script which creates a .html
      > > gallery with thumbs and links etc..
      > >
      > > I would like it to update the gallery
      > > and change the thumbs according to some
      > > random values every 60 minutes
      > >
      > > Anyone can suggest me a way to do that?[/color]
      >
      > I would suggest using cron/contab if you got access to it.
      > It will run your update script every chosen period of time
      >
      > --
      > Daniel Koñczyk
      > http://konczyk.net[/color]


      Comment

      • Rob @ Home

        #4
        Re: how to run a script automatically?

        sorry, wrong post...

        "Rob @ Home" <nospam@nospam. com> wrote in message
        news:RKs7b.2008 33$2x.57283@rwc rnsc52.ops.asp. att.net...[color=blue]
        > I'll try that...
        >
        > "Daniel Koñczyk" <drmartens@voru ta.eu.0rg> wrote in message
        > news:slrnblsjnu .74q.drmartens@ gnu.univ.gda.pl ...[color=green]
        > > Yang Li Ke <yanglike@sympa tico.ca> wrote:[color=darkred]
        > > > Hi there,
        > > >
        > > > I have a php script which creates a .html
        > > > gallery with thumbs and links etc..
        > > >
        > > > I would like it to update the gallery
        > > > and change the thumbs according to some
        > > > random values every 60 minutes
        > > >
        > > > Anyone can suggest me a way to do that?[/color]
        > >
        > > I would suggest using cron/contab if you got access to it.
        > > It will run your update script every chosen period of time
        > >
        > > --
        > > Daniel Koñczyk
        > > http://konczyk.net[/color]
        >
        >[/color]


        Comment

        • Yang Li Ke

          #5
          Re: how to run a script automatically?

          is there anythingelse ?

          Because I dont know how to set the chron jobs
          directly from a php script, is this possible?

          Yang

          --


          -------------------------------------------------------------------------
          FIGHT BACK AGAINST SPAM!
          Download Spam Inspector, the Award Winning Anti-Spam Filter



          "Daniel Koñczyk" <drmartens@voru ta.eu.0rg> wrote in message
          news:slrnblsjnu .74q.drmartens@ gnu.univ.gda.pl ...[color=blue]
          > Yang Li Ke <yanglike@sympa tico.ca> wrote:[color=green]
          > > Hi there,
          > >
          > > I have a php script which creates a .html
          > > gallery with thumbs and links etc..
          > >
          > > I would like it to update the gallery
          > > and change the thumbs according to some
          > > random values every 60 minutes
          > >
          > > Anyone can suggest me a way to do that?[/color]
          >
          > I would suggest using cron/contab if you got access to it.
          > It will run your update script every chosen period of time
          >
          > --
          > Daniel Koñczyk
          > http://konczyk.net[/color]


          Comment

          • Michael W. Cocke

            #6
            Re: how to run a script automatically?

            On Tue, 9 Sep 2003 20:21:10 -0400, "Yang Li Ke"
            <yanglike@sympa tico.ca> wrote:
            [color=blue]
            >is there anythingelse ?
            >
            >Because I dont know how to set the chron jobs
            >directly from a php script, is this possible?
            >
            >Yang[/color]

            First, make CERTAIN the system administrator is OK with the idea!
            Then all you need to do is open /etc/crontab and append the
            appropriate record - it's simple text. A better approach (IMHO),
            would be to set up cron to run a shell script and then have your php
            code rewrite that script as required... keeping your code from
            potentialy messing up a system service. ;-)>

            Mike-
            Mike-
            Mornings: Evolution in action. Only the grumpy will survive.
            -----------------------------------------------------

            Please note - Due to the intense volume of spam, we have
            installed site-wide spam filters at catherders.com. If
            email from you bounces, try non-HTML, non-encoded,
            non-attachments.


            ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
            http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
            ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---

            Comment

            • Sylvie Stone

              #7
              Re: how to run a script automatically?

              Michael W. Cocke <cocke@catherde rs.com> wrote in message
              [color=blue]
              > Then all you need to do is open /etc/crontab and append the
              > appropriate record - it's simple text.[/color]

              While this is correct in theory - in practise you should be much more
              careful. *If* the computer shuts down for any reason during this
              procedure your entire cron file wil be lost. For those of us will 30
              enttries in the cron file this is not good. A better way to write to a
              cron is to write to file and then overwrite the existing cron witht he
              new one. Like this:

              $ crontab -l > /tmp/newcron.file
              $ vi /tmp/newcron.file
              $ crontab /tmp/newcron.file

              Sylvie

              Comment

              • Andy Jeffries

                #8
                Re: how to run a script automatically?

                On Wed, 10 Sep 2003 05:48:29 -0700, Sylvie Stone wrote:[color=blue]
                > $ crontab -l > /tmp/newcron.file
                > $ vi /tmp/newcron.file
                > $ crontab /tmp/newcron.file[/color]

                surely:

                $ crontab -e

                does the same thing?

                Cheers,


                Andy

                Comment

                • Sylvie Stone

                  #9
                  Re: how to run a script automatically?

                  "Andy Jeffries" <news@andyjeffr ies.remove.co.u k>[color=blue]
                  > surely:
                  > $ crontab -e
                  > does the same thing?
                  > Andy[/color]

                  Hi Andy - sorry but crontab -e does *not* do the same thing. crontab
                  -e edits the cron file directly creating the same senario whereby if
                  the computer crashes you lose your file.

                  Sylvie

                  Comment

                  • Jon Kraft

                    #10
                    Re: how to run a script automatically?

                    Sylvie Stone <sylviestone@ca nada.com> wrote:
                    [color=blue]
                    > "Andy Jeffries" <news@andyjeffr ies.remove.co.u k>[color=green]
                    >> surely:
                    >> $ crontab -e
                    >> does the same thing?
                    >> Andy[/color]
                    >
                    > Hi Andy - sorry but crontab -e does *not* do the same thing. crontab
                    > -e edits the cron file directly creating the same senario whereby if
                    > the computer crashes you lose your file.[/color]

                    Hi Sylvie,

                    You are wrong, crontab -e does exactly that, copies the current crontab into
                    a temp file, edits the tempfile and overwrites the current crontab.

                    JOn

                    Comment

                    • Andy Jeffries

                      #11
                      Re: how to run a script automatically?

                      On Thu, 11 Sep 2003 04:38:43 -0700, Sylvie Stone wrote:[color=blue][color=green]
                      >> surely:
                      >> $ crontab -e
                      >> does the same thing?
                      >> Andy[/color]
                      >
                      > Hi Andy - sorry but crontab -e does *not* do the same thing. crontab
                      > -e edits the cron file directly creating the same senario whereby if
                      > the computer crashes you lose your file.[/color]

                      Sorry to be so argumentative, but you are blatently wrong!!!!

                      Looking the source code for crontab (vixie_cron, 3.0.1, crontab.c) reveals
                      that a -e switch does the following:

                      1)Opens the existing crontab readonly (this won't cause the loss of a
                      file if the computer crashes) (line 305)

                      2)Opens a new file called /tmp/crontab.{PID} (where PID is the Process
                      Identifier for the crontab process) with write access (this won't cause
                      the loss of the previous file if the computer crashes) (line 318/319)

                      3)Copies the content of the readonly original opened in step 1 to the new
                      temp file opened in step 2 (lines 357-359)

                      4)It then forks and opens the editor to edit the temp file (line 393)

                      5)The parent process waits for the editor to finish (line 423)

                      6)If all was OK with the edit, then call the replace_cmd function (line
                      451 calling line 491)

                      7)Only at this point does the real crontab file get opened for write
                      access and is liable to be lost if the power is lost.


                      However this is also the point that occurs if you just put the file on the
                      command line (it sets a default option of opt_replace (line 199) and sets
                      the filename of the incoming file to the file you specify (line 200) and
                      runs the replace_cmd in exactly the same manner (line 124)

                      So, sorry to be nasty in the first line, but that's the great thing about
                      Linux - it's not "I think it works this way" - it's "I know it works this
                      way because I've looked at the source code and it blatently does!".

                      Cheers,


                      Andy

                      Comment

                      • Andy Jeffries

                        #12
                        Re: how to run a script automatically?

                        On Thu, 11 Sep 2003 12:52:37 +0100, Jon Kraft wrote:[color=blue][color=green]
                        >> Hi Andy - sorry but crontab -e does *not* do the same thing. crontab
                        >> -e edits the cron file directly creating the same senario whereby if
                        >> the computer crashes you lose your file.[/color]
                        >
                        > Hi Sylvie,
                        >
                        > You are wrong, crontab -e does exactly that, copies the current crontab into
                        > a temp file, edits the tempfile and overwrites the current crontab.[/color]

                        Dammit Jon!!!!

                        I was busy looking in to the source code while you post a two line reply!
                        Are you trying to remove all the fun from my day ;-)

                        LOL!!

                        Cheers,



                        Andy


                        Comment

                        • Jon Kraft

                          #13
                          Re: how to run a script automatically?

                          Andy Jeffries <news@andyjeffr ies.remove.co.u k> wrote:
                          [color=blue]
                          > On Thu, 11 Sep 2003 12:52:37 +0100, Jon Kraft wrote:[color=green][color=darkred]
                          >>> Hi Andy - sorry but crontab -e does *not* do the same thing. crontab
                          >>> -e edits the cron file directly creating the same senario whereby if
                          >>> the computer crashes you lose your file.[/color]
                          >>
                          >> Hi Sylvie,
                          >>
                          >> You are wrong, crontab -e does exactly that, copies the current crontab
                          >> into a temp file, edits the tempfile and overwrites the current crontab.[/color]
                          >
                          > Dammit Jon!!!!
                          >
                          > I was busy looking in to the source code while you post a two line reply!
                          > Are you trying to remove all the fun from my day ;-)
                          >
                          > LOL!![/color]

                          Well, Andy, you hopefully will be cheered up to know your thorough analysis
                          has entertained, educated, and, not least, brightened my day ;))

                          (Was I glad I'd guessed right ...)

                          JOn

                          Comment

                          • Andy Jeffries

                            #14
                            Re: how to run a script automatically?

                            On Thu, 11 Sep 2003 13:20:18 +0100, Jon Kraft wrote:[color=blue][color=green][color=darkred]
                            >>> You are wrong, crontab -e does exactly that, copies the current crontab
                            >>> into a temp file, edits the tempfile and overwrites the current crontab.[/color]
                            >>
                            >> Dammit Jon!!!!
                            >>
                            >> I was busy looking in to the source code while you post a two line reply!
                            >> Are you trying to remove all the fun from my day ;-)[/color]
                            >
                            > Well, Andy, you hopefully will be cheered up to know your thorough analysis
                            > has entertained, educated, and, not least, brightened my day ;))[/color]

                            I hate being wrong, so when I'm right I like to come out gloating with all
                            facts at my disposal.

                            If I had been wrong, I'd have been REAL quite on this group for a few
                            days....
                            [color=blue]
                            > (Was I glad I'd guessed right ...)[/color]

                            "guessed"? :-) Surely you meant "Was I glad I knew that" (don't worry,
                            I'll cover for you that it was a slip of the tongue!)

                            Cheers,


                            Andy

                            Comment

                            • Michael W. Cocke

                              #15
                              Re: how to run a script automatically?

                              On 10 Sep 2003 05:48:29 -0700, sylviestone@can ada.com (Sylvie Stone)
                              wrote:
                              [color=blue]
                              >Michael W. Cocke <cocke@catherde rs.com> wrote in message
                              >[color=green]
                              >> Then all you need to do is open /etc/crontab and append the
                              >> appropriate record - it's simple text.[/color]
                              >
                              >While this is correct in theory - in practise you should be much more
                              >careful. *If* the computer shuts down for any reason during this
                              >procedure your entire cron file wil be lost. For those of us will 30
                              >enttries in the cron file this is not good. A better way to write to a
                              >cron is to write to file and then overwrite the existing cron witht he
                              >new one. Like this:
                              >
                              >$ crontab -l > /tmp/newcron.file
                              >$ vi /tmp/newcron.file
                              >$ crontab /tmp/newcron.file
                              >
                              >Sylvie[/color]

                              If you take a look at the rest of my previous message, you'll notice
                              that I offered a preferable method that doesn't involve writing the
                              crontab file directly - it depends on what the OPs exact situation is.

                              Mike-

                              Mornings: Evolution in action. Only the grumpy will survive.
                              -----------------------------------------------------

                              Please note - Due to the intense volume of spam, we have
                              installed site-wide spam filters at catherders.com. If
                              email from you bounces, try non-HTML, non-encoded,
                              non-attachments.


                              ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
                              http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
                              ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---

                              Comment

                              Working...