#handle schedule time execute a function

4 messages · Page 1 of 1 (latest)

lavish shell
#

hi i want to execute something when the current time and the checkout time is the same. what is the best practices so that there will be no bugs.

#

and for future if the db server is down during that time, any suggestion to still execute the function eventhough the currentime > checkout time. but when it is done, it will not execute again. so its a one time thing

solar cave
#

how precise do you need this timing to be?

#

The usual naïve solution is to store your "future events" in a database with the time they need to execute at ("scheduledAt") and either a boolean "complete=false" or "completedAt=null" and periodically (once in a day, hour or monute, depending on the needed precision) do a select on the table with "where now() >= scheduledAt AND complete=false". Then process these and mark them with "complete=true"