停止远程服务器 PHP 上的无限循环

发布于 2024-12-05 20:45:48 字数 221 浏览 0 评论 0原文

我有一个简单的无限 for 循环,如下所示:

set_time_limit (0);
for (;;)
{
    ... //Doing some stuff including to write to a file
    sleep(300);
}

它在我的服务器上运行。 (共享主机帐户)

我到底该如何阻止它?

I have a simple infinite for loop looking like this:

set_time_limit (0);
for (;;)
{
    ... //Doing some stuff including to write to a file
    sleep(300);
}

It's running on my server. (Shared hosting account)

How on earth can I stop it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

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

评论(5

慵挽 2024-12-12 20:45:48

杀死进程。假设您可以通过 ssh 访问控制台并且您的服务器在 Linux 上运行:

ps -ef | grep php // to get a list of php-processes

kill [process-id] // kill the process by process-id

kill the process. assuming you can get access to the console via ssh and your server runs on linux:

ps -ef | grep php // to get a list of php-processes

kill [process-id] // kill the process by process-id
勿忘心安 2024-12-12 20:45:48

假设您正在使用共享托管服务器,并且无法访问命令行或 ssh 或托管支持团队...

您最好的办法是使用网站管理面板来触发 php 重新启动。

当您切换 php 版本/更改 php ini 参数(例如内存限制)时会发生这种情况

Assuming you are working with a shared hosting server, and have no access to command line or ssh or hosting support team...

your best shot would be using your website management panel to trigger php restart.

this happens when you switch php version / change php ini params such as memory limit

山有枢 2024-12-12 20:45:48

您可能需要联系您的托管服务并要求他们终止您的脚本。您很可能没有执行访问权限或 ssh 访问权限。也许您应该在下次创建无限循环时建立退出程序的可能性。

You might want to contact your hosting service and ask them to kill your script. Most likely you don't have execute-access or ssh-access. Maybe you should build a possibility to quit your program next time you create an infinite loop.

神也荒唐 2024-12-12 20:45:48

我通过 SSH 登录并尝试终止该进程,但它似乎不起作用 - 可能是不正确的进程,因为那里有很多进程。

作为最后的手段,你总是可以重新启动 apache;这会修复它;-)

I logged in via SSH and tried killing the process but it didn't seem to work - possibly the incorrect process as there were quite a few there.

You can always restart apache as a last resort; that will fix it ;-)

旧人 2024-12-12 20:45:48

您提到写入文件。

但是,如果您正在写入数据库,则可以使用数据库工具临时重命名字段,这将触发错误并停止脚本。

共享服务器、快速开发和打字错误的问题。

You mentioned writing to a file.

But if you were writing to a database you can use your database tool to temporarily rename a field which would trigger an error and stop your script.

The woes of shared servers, rapid dev and typos.

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