Forum Moderators: coopster

Message Too Old, No Replies

PHP Chron

Start a command at a particular time

         

Alexander2005

10:04 pm on Feb 1, 2005 (gmt 0)

10+ Year Member



Hey people, i am a bit new to this forum bit, but have a reasonable knowledge of php. I am trying to have a script run at a particular time each day. i want the script to calculate the diffence between a time stamp on a database entry and the current time. if it is greater than 30 days (60 x 60 x 24 x 30) then i want the database entry to be moved to another table. Anyone got any ideas or sample script?

Thanks for any help

coopster

12:34 pm on Feb 2, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, Alexander2005.

This seems like a fairly straightforward application. Why not give it your best attempt and we'll help you with the details if you get stuck. I would simply write the script first, test it, then when you know it works as designed put it on an automated task job within your OS (cron, etc). The script might basically follow this design...

  1. Connect to the database
  2. Loop through rows using CURRENT_TIME to check against database entries
  3. INSERT those found INTO the secondary table
  4. Remove it from this table
  5. Optionally print a list of entries moved
  6. Close the database connection