I am looking for a code that do an event at spesified time at day!

Discussion in 'PHP' started by Sniper192, Feb 25, 2007.

  1. #1
    Hi All
    The matter is that I have a counter at my site, stores the values at a text file, and I want to reset this counter automatically to zero every day at a specified time, lets say at 6 pm, so any body have ideas how to do that?

    Regards
     
    Sniper192, Feb 25, 2007 IP
  2. keiths

    keiths Peon

    Messages:
    109
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Well the only way to do it at exactly a specified time is to use a cron job on the server to run a php file.

    The other thing you could do is kind of fake it and check everytime a page is loaded and see if it is past 6pm and if it has been set to 0 or not for that day.
     
    keiths, Feb 25, 2007 IP
  3. Sniper192

    Sniper192 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    The second one is not good because it is static in way or another.
    About the first one, I haven't heared about it, you mean I need to contact the server administrator to do this for me?!! or I couldn't get it yet?
     
    Sniper192, Feb 25, 2007 IP
  4. m0nkeymafia

    m0nkeymafia Well-Known Member

    Messages:
    399
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    125
    #4
    If you have a cpanel look for Cron Jobs [CTRL+F to find the text is easiest]

    Basically google cron jobs for a tutorial but they look like this:

    * * * * * * * phpbin myfiletoexecute.php

    the *'s represent when you want the cron job to fire, *'s mean everytime, so this would fire every second of every day. You can put a 0 in the second column and a 30 in the minute column to make it fire once every 30mins and so forth. As i said google cron jobs there are many tutorials
     
    m0nkeymafia, Feb 25, 2007 IP
  5. bochgoch

    bochgoch Peon

    Messages:
    1,918
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #5
    cron is the unix solution for running scheduled tasks (in short - run a program at a specified time). easiest solution for you if you're not familiar with these concepts is to contact your host...

    first question is what operating system is your site hosted on?
     
    bochgoch, Feb 25, 2007 IP