杀死后台php脚本(共享主机)
我使用ignore_user_abort()函数创建了一个在后台运行的脚本。然而,我很愚蠢,没有插入任何类型的代码来使脚本停止,现在它每 30 秒发送一次电子邮件......
有什么方法可以停止脚本吗?我位于共享主机中,因此无法访问命令提示符,也不知道 PID。
I created a script that runs in the background using the ignore_user_abort() function. However, I was foolish enough not to insert any sort of code to make the script stop and now it is sending e-mails every 30 seconds...
Is there any way to stop the script? I am in a shared hosting, so I don't have access to the command prompt, and I don't know the PID.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
那么不。
但您确定您没有任何 shell 访问权限吗?即使通过 PHP 也可以吗?如果你这样做,你可以尝试......
如果你可以从中识别进程,那么......
即使你无权运行 shell 命令,你也可以找到 pid在 /proc (在 Linux 系统上)并使用 POSIX 扩展终止它......
Then no.
But are you sure you don't have any shell access? Even via PHP? If you do, you could try....
...and if you can identify the process from that then....
And even if you don't have access to run shell commands, you may be able to find the pid in /proc (on a linux system) and terminate it using the POSIX extension....
我昨天就来到这个话题了!我错误地在一个不应该被访问的页面中出现了无限循环,这将我的 I/O 增加到了 100,CPU 使用率增加到了 100
I/ O
是因为一些php 错误
,它正在被记录
,并且日志文件大小的增长超出了任何人的想象。上述技巧在我的
共享主机
上都不起作用。我的解决方案
在 cPanel 中,转到 PHP 版本(当前版本除外)
选择任意 PHP 版本暂时。
然后
应用更改
。它工作的原因
具有一些 php 错误的无限循环的脚本是一个进程,所以我只需要杀死它,更改 php 版本以加强 php 和 Apache 等服务的重新启动,并且因为之前涉及重新启动进程被终止,随着
I/O
和CPU
使用稳定下来,我感到放松。另外,我在手动更改 php 版本之前修复了该错误:)I came to this thread Yesterday! I by mistake had a infinite loop in a page which was not supposed to be visited and that increased my
I/O to 100
andCPU usage to 100
I/O
was because of somephp errors
and it was gettinglogged
and log file size was increasing beyond anyone can think.None of the above trick worked on my
shared hosting
.MY SOLUTION
In cPanel, go to PHP Version (except that of current)
Select any PHP Version for time being.
And then
Apply Changes
.REASON WHY IT WORKED
The script which had infinite loop with some php errors was a process so I just needed to kill it, changing php version reinforce restart of services like php and Apache, and as restart was involved earlier processes were killed, and I was relaxed as
I/O
andCPU
usage stabilized. Also, I fixed that bug before hand changing the php version :)你是如何部署脚本的?当然你可以删除它(如果这是一个可接受的选项)。否则修改它并插入一些逻辑,只允许它根据服务器时间每 n 分钟/小时/天发送一次邮件?
关于。停止脚本执行(或者更确切地说是系统尝试执行它),您是如何安排它执行的?它是某种类型的 crontab 图形用户界面还是其他什么?你能不只是撤消你在那里所做的事情吗(因为你无法访问命令行/终端)?
罗布·甘利
how did you deploy the script? surely you can just remove it (if that's an acceptable option). otherwise modify it and insert some logic to only allow it to send a mail once every n mins/hours/days based on the server time?
re. stopping the script from executing (or rather the system trying to execute it) how did you schedule it for execution? is it some type of gui to a crontab or something? can you not just undo what you did there (seeing as you have no access to the command line/terminal)?
rob ganly
简单地 。
打电话给支持,取消它。
下次,不要执行你无法控制的事情。
Simply .
Call the support, get it cancelled.
Next time, don't execute something you can't control.