Launching a query everyday on hour x ?

Discussion in 'PHP' started by fatabbot, Jan 19, 2007.

  1. #1
    Is it possible with php and mysql to execute an update sql query every day at a specific timestamp ?
     
    fatabbot, Jan 19, 2007 IP
  2. mihaidamianov

    mihaidamianov Well-Known Member

    Messages:
    1,434
    Likes Received:
    111
    Best Answers:
    0
    Trophy Points:
    190
    #2
    No, as far as I know. That stuff is done with cron jobs. Setting a cron job to run a php file at a defined time/loop is possible.
     
    mihaidamianov, Jan 19, 2007 IP
  3. Kalyse

    Kalyse Peon

    Messages:
    1,221
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #3
    cron is the only way.
     
    Kalyse, Jan 19, 2007 IP
  4. fatabbot

    fatabbot Well-Known Member

    Messages:
    559
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    138
    #4
    No triggers ?
     
    fatabbot, Jan 19, 2007 IP
  5. mihaidamianov

    mihaidamianov Well-Known Member

    Messages:
    1,434
    Likes Received:
    111
    Best Answers:
    0
    Trophy Points:
    190
    #5
    Seriously how do you think you could trigger an event on your server?! Unless you're there and double-click it yourself, your only choice is a cronjob.
     
    mihaidamianov, Jan 19, 2007 IP
  6. Kalyse

    Kalyse Peon

    Messages:
    1,221
    Likes Received:
    24
    Best Answers:
    0
    Trophy Points:
    0
    #6
    the trigger is the cron.

    just set a cron up on your script. you could even do it from another server and just use wget
     
    Kalyse, Jan 19, 2007 IP
  7. mariush

    mariush Peon

    Messages:
    562
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #7
    If your site has visitors in the interval when you want to do that sql query, than you could use:
    register_shutdown_function()
    PHP:
    to start automatically a function from your php script AFTER everything is executed and connection to the user closed.

    The function could check the time and if it's around the timestamp you want (+/- a few seconds/minutes - depends on how many visitors your site has), you could run the query.

    The best thing is still to use cron jobs but if the hosting company doesn't allow those, then this may help.
     
    mariush, Jan 19, 2007 IP
  8. Shoemoney

    Shoemoney $

    Messages:
    4,474
    Likes Received:
    588
    Best Answers:
    0
    Trophy Points:
    295
    #8
    Shoemoney, Jan 19, 2007 IP