PHP MySQL Cron job help needed

9 replies
I am trying to automate my site a little by implementing some
repetitive taskes I do everyday into a cron job php script.

I have several pieces of MySQL code that I use directly into
my database using phpmyadmin and so what I want to do is
create a php page, say cron.php, and then put all these individual
pieces of MySQL scripts in there.

So it would be something like.

DELETE these items

then

UPDATE these items

then

UPDATE these different items.


So what I would like to know is how to join up
these different items in php/MySQL.

I would also like to allow about 15 seconds in between each command to allow
the database to perform the task safely. S ohow do I space out each command by
15 seconds.

Any help much appreciated.

Terry
#cron #job #mysql #needed #php
  • Profile picture of the author KirkMcD
    You don't need to space them out. Just put all the commands into one batch file and execute that.
    {{ DiscussionBoard.errors[2601589].message }}
  • Profile picture of the author green2010
    Banned
    [DELETED]
    {{ DiscussionBoard.errors[2607793].message }}
    • Profile picture of the author jon_martinez
      Hey Terry,
      Are you putting a semicolon at the end of each line?

      That might do the trick....

      If it doesn't, go ahead and copy/paste the PHP code into your post. I'll take a look at it and give you my two cents.

      Jon
      {{ DiscussionBoard.errors[2607811].message }}
      • Profile picture of the author mojojuju
        It would be easy to make a bash or php script to do what you need to do.
        Signature

        :)

        {{ DiscussionBoard.errors[2608892].message }}
        • Profile picture of the author hhunt
          Originally Posted by mojojuju View Post

          It would be easy to make a bash or php script to do what you need to do.
          A sample code would have been better than just a simple comment that does not mean anything to the OP.
          {{ DiscussionBoard.errors[2611711].message }}
          • Profile picture of the author mojojuju
            Originally Posted by hhunt View Post

            A sample code would have been better than just a simple comment that does not mean anything to the OP.
            Thank you forum assistant lady. However, I'll trust that the OP does not need you to speak on his behalf.
            Signature

            :)

            {{ DiscussionBoard.errors[2611936].message }}
            • Profile picture of the author terry1288
              Thanks jon_martinez

              It appears it was as simple as putting the semi colon at the end of each
              update/delete instruction.

              The single instructions worked OK in phpmyadmin without the semi colon
              but when using more than one instruction did require one at the end of
              each instruction phrase.

              And yes I have to agree with hhunt if you are going to make a comment
              which sounds as though you know or possibly know the answer then surely
              common sense would suggest to put either the answer or an example of the answer in your post as this will not ony help me but other people who read the post.

              None the less thank you all for your comments and it appears I have the answer
              now which is good news.

              Terry
              {{ DiscussionBoard.errors[2611993].message }}
  • Profile picture of the author jon_martinez
    Glad to help Terry!

    Have fun,
    Jon
    {{ DiscussionBoard.errors[2616003].message }}

Trending Topics