dongxia4880 2011-02-16 16:23
浏览 94
已采纳

定时脚本PHP

I am trying to figure out how to do time scripting in PHP. Basically let's say in my application, I want to do a task at timed intervals (e.g., send email notification to users everyday, do some database cleanup at certain times, etc.) How is this type of scripting (scheduling) is done in PHP? If not possible in PHP, then how to do it and in what language? I am both Linux and Windows sharing hosting accounts, so I would like this method if possible to be universal.

Any help is appreciated.

  • 写回答

5条回答 默认 最新

  • duanchui1955 2011-02-16 16:27
    关注

    I just schedule cron jobs that run PHP scripts.

    */5 * * * * php /var/www/cron/cleanup-db.php
    

    An alternate (Windows-compatible) approach would be to run a persistent PHP script which sleeps for an interval, and on wakeup it checks to see if any jobs need to be run. For example, check to see if any pending requests have not had a response or a reminder email in N hours.

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

报告相同问题?

悬赏问题

  • ¥15 孟德尔随机化结果不一致
  • ¥20 求用stm32f103c6t6在lcd1206上显示Door is open和password:
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法