开发者

Execute script at variable time

I'm aware of cron jobs to execute commands at a certain time, but what if 开发者_C百科that time is not constant? For instance, suppose a user asks for a reminder email exactly 1hr after signing up for something, is there an easy way to go about doing this?

Timing is critical. I am actually trying to create AI that will essentially act on its own but only at variable points during the day. Any help would be appreciated!


You can use at to schedule jobs for specific times. cron is for repeating jobs, at is for one-shot/oddball interval ones. Both have a resolution of 1 minute, though, so you can't specify a start period with seconds granularity.

The command's available on both Unix/Linux and Windows.


Here a workable flow:

  1. user Requests email in 1 hour
  2. You insert into the a table action (action_id, time)
  3. On the PHP server create a cron job to check the action in the action table every minute, then do the action that need to be done at that time

That is a simple example from the request. It might get a bit more complex then that.

EDIT : this suggestion might be good only if you need to be very precise with the time management!


if you dont wanna use the cron triggers and you are not comfortable with them here are two php scheduling libraries..

1) http://www.php.brickhost.com/

2) http://www.phpjobscheduler.co.uk/

Try them if you like:

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜