dongnaoxia0927 2018-05-01 10:13
浏览 132

MySql - 获取需要在当前分钟运行的任务

Situation:

I have a table with tasks (which need to run at different intervals) and two php scripts (initator.php & worker.php). The initiator script is run every minute by cron and the intervals are stored in a column together with the tasks.

The initiator script should check which tasks should be send to the worker script.

so the question is: How could I determine which tasks need to be run in the current minute?

I tried it with a 'next' column (mysql timestamp), the initiator script checks if the next column matches the current date without seconds but I think this isn't a good solution because of delays and execution times.

  • 写回答

1条回答 默认 最新

  • doudi4621 2018-05-01 11:58
    关注

    I don't understand your explanation of why you think "next" is a bad idea.

    A key question is how scalable the solution needs to be. If you can prove that you will never have more than 20 records, then its not too onerous to read each task record and calculate the next scheduled time / check if it falls within a particular window. But when you get to hundreds of records, then it's a very different story. There's no way to create an index which can be used by the DBMS in the absence of a next-planned-execution-time attribute.

    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效