当服务器负载较低时启动包含大量 SQL 调用的 PHP 脚本?

发布于 2024-12-11 05:12:12 字数 83 浏览 0 评论 0原文

我是使用 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技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜雨飘雪 2024-12-18 05:12:12

只需使用较高的nice值(例如19)运行PHP进程 - 这样,它仅在没有其他进程需要时才获得处理时间。

例如,

$ nice -n 19 php path/to/your/php/script.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

$ nice -n 19 php path/to/your/php/script.php

on your shell.

You can also use php's renice functionality: http://php.net/manual/en/function.proc-nice.php

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文