Executing PHP code at specific times

Discussion in 'Site & Server Administration' started by Weirfire, May 1, 2005.

  1. #1
    I'm programming some code at the moment which I'd like to activate at midnight every night. Is there a way of doing this so that the PHP code is executed at specific times during the day?

    I'd be interested in all the different solutions people have for this as I'm sure there will be a few. :)
     
    Weirfire, May 1, 2005 IP
  2. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #2
    How about a cron job? /etc/crontab
     
    digitalpoint, May 1, 2005 IP
  3. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #3
    I've never heard of it but I'll do a bit of research on it.

    Do you have any handy resources on this method which you would recommend?
     
    Weirfire, May 1, 2005 IP
  4. digitalpoint

    digitalpoint Overlord of no one Staff

    Messages:
    38,334
    Likes Received:
    2,613
    Best Answers:
    462
    Trophy Points:
    710
    Digital Goods:
    29
    #4
    Do a man crontab on your shell... basically just lets you run anything you want anytime you want.
     
    digitalpoint, May 1, 2005 IP
  5. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #5
    Thanks Shawn

    That's helpful stuff :)
     
    Weirfire, May 1, 2005 IP
  6. TommyD

    TommyD Peon

    Messages:
    1,397
    Likes Received:
    76
    Best Answers:
    0
    Trophy Points:
    0
    #6
    weirfire,

    do you have a dedicated server, or shared hosting with a control panel like cpanel?
    tom
     
    TommyD, May 1, 2005 IP
  7. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #7
    Hi Tommy,

    I have a reseller account. I've contacted my hosts asking them if it's possible to run cronjobs. What do you reckon?
     
    Weirfire, May 1, 2005 IP
  8. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #8
    I can see cron jobs in my control panel now.

    I'll see if I can test 1 out :)
     
    Weirfire, May 1, 2005 IP
  9. TommyD

    TommyD Peon

    Messages:
    1,397
    Likes Received:
    76
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Tip: Test your php pages directly, so you can rule out code problems if scheduled taskes don't work.

    tom
     
    TommyD, May 1, 2005 IP
  10. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #10
    Thanks Tommy,

    I've basically just used the mail() command to send myself an email at the time of execution. It'll be a while before the program is actually ready to fully test. If this works, then I'm going to be a very happy man lol
     
    Weirfire, May 1, 2005 IP
  11. Weirfire

    Weirfire Language Translation Company

    Messages:
    6,979
    Likes Received:
    365
    Best Answers:
    0
    Trophy Points:
    280
    #11
    Ok, I got my test cron job executing which is great news! :)

    I'll let you know what the project I'm working on is in about a months time. It should be quite interesting and fun for at least the UK population.
     
    Weirfire, May 1, 2005 IP