当服务器负载较低时启动包含大量 SQL 调用的 PHP 脚本?
我是使用 CRON 来做到这一点,还是有其他系统?我以前从未这样做过,但我想在服务器负载停止时运行一些 PHP 脚本,并在服务器负载增加时暂停脚本运行。
Do I use CRON to do this, or is there some other system? I have never done this before, but I would like to run some PHP scripts when the server load dies down and pause the scripts from running if the server load picks up.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需使用较高的nice值(例如19)运行PHP进程 - 这样,它仅在没有其他进程需要时才获得处理时间。
例如,
在您的 shell 上使用。
您还可以使用 php 的 renice 功能: http://php.net/manual/en /function.proc-nice.php
Just run the PHP process with a high nice value, e.g. 19 - that way, it only gets processing time when no other process needs it.
For example, use
on your shell.
You can also use php's renice functionality: http://php.net/manual/en/function.proc-nice.php