duanbiyi7319 2013-09-24 03:38 采纳率: 100%
浏览 20

每次用户刷新页面时,都会从URL运行PHP脚本

I need to run a PHP script from another site, without the use of CRON, so that will be called whenever anyone comes or refreshes the page.

The script will perform some kind of update my database, it is possible that it takes several tens of seconds, so I needed to run the PHP script so that it also does not limit the site visitor, from where the script will be called.

But I do not want to make the script really starts up every time someone visits or refreshes the page, I would like to limit one minute and so, before calling the script, I would like to put into MySQL database current time someone (who is the one - the one who was first) arrives or refreshes the page, and in the case where someone just to update the page is first compares the current time with the database from the last call script, and if the difference is less than one minute, so the script does not call, but if more than one minute is executed while the database again writes the current time with the last script execution.

I do not need any response from running the script. Importantly, it shall not affect the page loading user, where it should be called.

Thanks for help

  • 写回答

2条回答 默认 最新

  • dtu11716 2013-09-24 03:44
    关注

    Ok, if javascript is not an option you can do a little bit more research on php forking. It's basically php version of Thread but much more limited. So you can actually fork a child php process to run in the background while the main process still doing the usual thing. So it won't affect your day to day process.

    http://php.net/manual/en/function.pcntl-fork.php

    评论

报告相同问题?