PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I want to trigger an action based on time. What is the best way to do it? The only way i think of based on my skill is using sleep to repeatly check state of an event before triggering an action. Is there any other way ? I'll do the reading, just need to know what to find for. Thanks
Oh yeah, i need to communicate with MySQL as well. I will get the time and date values from MySQL and perform an action based on the database given. Will Crontab help?
How specific is the time and date? I would make a cron job that runs my script every minute, and the first thing my script does is check the date and time, if they dont match then die else execute the rest of the script. That way you don't have to trust that your script isn't going to crash out.
Perhaps accurate in minutes will do. I can create a php script which will check for event in MySQL on a minute to minute basis perhaps ? Will crontab produce overhead ?
What sort of action are you wanting it to do? The reason I ask is because many actions that people want to do in "timely" manors are viewer dependant; they need to be seen to have any use. In which case, it can, most often, be done based on someone interacting with the server.
What i have now
1. set a date and time
2. set an event
3. phpscript queries database on a minute to minute basis, i query base on day followed by time
3. perform the event matching time and date
Say i set an event in my database based on a calender reminder that i'm suppose to send my friend a file at some date and time. Or maybe send an email for a non-responsive action. The server side will automatically trigger this action. That is what i'm trying to do. But i don't want to incur too much overhead looping and looping to check for matching criteria in my database on a minute to minute basis.
There are php calendar codes but none of them are able to trigger events. One of the trigger I am thinking of is to contact another web server to send information when time trigger.