dongshang1529 2010-09-14 06:48
浏览 25
已采纳

用户事件后运行脚本,但不影响页面加载?

I'd like to trigger a script to update some statistics when a user submits a new record, but I don't want the user to have to wait for the script to finish before being redirected.

>-- Time -->
                        > redirect User -> User Does Stuff -> more stuff -> etc
                       /                   
User Input -> Submit ->
                       \
                        > updating stats in background -> Possibly still running

What's the best way to do this in PHP?

EDIT for Fabrik

Users would like to see immediate feedback reflecting the addition of their new data, but this new data only comes in 2 or 3 times a day, so I think an interval-based CRON job might be an unnecessary use of server resources and also fail to satisfy their need for urgency. Hope this helps!

  • 写回答

3条回答 默认 最新

  • dongre6404 2010-09-14 06:59
    关注

    I did a quick google search for php background process and most of the hits are suggesting using either exec or shell_exec to call the script you want to run in the background.

    Edit: This article seems to be the most relevant to your question.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 cruise如何仿真不同温度下车辆的经济性?
  • ¥20 扑克牌游戏的完整代码
  • ¥88 求帮安装Python架构的vnpy
  • ¥20 逻辑回归法分析品牌知名度和购买意向
  • ¥15 华为云主机-异常连接
  • ¥50 vue 成绩列表 输入成绩,并统计各分数段人数
  • ¥20 请教怎么绕过这个卡密系统 大家交流一下
  • ¥15 设计数字电路得到要求结果
  • ¥15 hfss 组天线阵列报错:The A and B vectors must be parallel to the XY plane,如何解决?
  • ¥30 ansible连接设备报错