dpaal28266 2015-06-12 10:00
浏览 193
已采纳

Php计划在10分钟后运行一个功能

There is a function A and function B

What I would like to do is , after running function A, it start the counting , after 10 minutes it run the function B (for one time only).

Notice that during the counting, the function A can be run again , so that can be schedule multiple counting to run function B.

After some studies I found something call cron job, but as I use CPanel (linux based) , it seems it is design for repeat job instead of one time job.

Also, if I use sleep() with 10 minute the server will no doubt busy and it has problem if the user leave before 10 minute

How to achieve that? I have already written the program for function B. Just need to run the url after 10 minutes after running the function A.

http://my_domain.com/yoga/api/video/check_processed

Thanks a lot.

  • 写回答

1条回答 默认 最新

  • dragam0217 2015-06-12 10:11
    关注

    When function A is called then you should insert timestamp in another database table.

    You can also add another column in that table which will have (timestamp+10 minutes).

    Now create a function say runCron() that will find out both the columns time difference and then when it is 10 minutes then it will execute function B. Set a cron job which will call runCron every minute.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP