1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

running a code in a specific minute

Discussion in 'PHP' started by asmon, Feb 19, 2008.

  1. #1
    I have a database table with lots of different times.
    if for example one row in the database shows 16:32pm today, then i need a code to be performed exactly when the minute turns 32 involving information in that row.

    I have thousands of rows, some points to the same exact time.

    The best idea i have in mind is activating a code every minute to check current
    time against the database and selecting the required rows.
    Is there a better way?

    If my question is not understandable, i can try to rephrase it, sorry for that.
     
    asmon, Feb 19, 2008 IP
  2. fairuz.ismail

    fairuz.ismail Peon

    Messages:
    232
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    yes, you can setup a cronjob for that..run that script let say every minute and compare the values in the rows with current time. i think that would do the job.
     
    fairuz.ismail, Feb 19, 2008 IP
  3. CATTechnologies

    CATTechnologies Guest

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Here is my thoughts...

    The best idea I have in mind is activating a code every minute to check current
    time against the database and selecting the required rows.
    Yes that is the way. In this way you can get the code to be performed exactly when the minute turns 32 involving in that row. Let me know for more... call me @cattechnologies.com
     
    CATTechnologies, Feb 21, 2008 IP
  4. false

    false Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    and no need to worry about load - 1 query per minute isn't load for database, even if it is a complicated query
     
    false, Feb 21, 2008 IP
  5. asmon

    asmon Member

    Messages:
    56
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #5
    never experienced with cronjobs before but at first i'm trying to run it on my own computer using "task scheduler" of windows vista.
    I have a little problem because i set an editor to open my php files
    so when i put the file in task scheduler it opens it with the editor instead of a browser.
    it's not related to the forum but maybe someone know how to set the task scheduler to open the
    file with a specific software (browser in this case) ?
     
    asmon, Feb 21, 2008 IP
  6. walkere

    walkere Active Member

    Messages:
    112
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    58
    #6
    I haven't tried to do this specifically, but here's some conjecture...

    You can't tell Task Scheduler to open a .php script directly. It'll assume you want to edit the script, not execute it.

    Instead, you could tell Task Scheduler to open a browser window to the location of your php script. Or you could use the php executable (with your script as an argument) to execute it.

    - Walkere
     
    walkere, Feb 21, 2008 IP
  7. asmon

    asmon Member

    Messages:
    56
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #7
    Thanks.. didn't know "argument" is where i suppose to type the script's URL. IE only shows the script itself (the code) but FIREFOX works and runs the script, good enough...
     
    asmon, Feb 21, 2008 IP