简体   繁体   English

如何在Windows中杀死正在运行的php脚本

[英]How to kill a running php script in windows

I have a php script running in an infinite loop that I need killed without restarting apache. 我有一个PHP脚本在无限循环中运行,我需要杀死而不重启apache。

I have access to the server via remote desktop. 我可以通过远程桌面访问服务器。 Please advise. 请指教。

Find the running scripts you want to kill: 找到要杀死的正在运行的脚本:

tasklist /v | find "php"

Make note of the process ID, kill it with: 记下进程ID,将其杀死:

taskkill /PID 3776

Same as doing: 和做:

ps aux | grep php

kill 3776

Have you tried: 你有没有尝试过:

Windows task manager->Processes->apache ? Windows任务管理器 - >进程 - > apache?

It should be there, simply end the process. 应该在那里,简单地结束这个过程。

EDIT - 编辑 -

Just saw that you don't want to kill apache. 刚刚看到你不想杀死apache。

I'm not sure that's possible, as PHP runs as an apache module I believe. 我不确定这是可能的,因为我认为PHP作为apache模块运行。

在任务管理器中查找占用100%CPU的apache“fork”,然后将其删除。

You can try this: https://serverfault.com/questions/229435/how-to-break-from-infinite-loop-caused-by-php-script-running-as-root 你可以尝试这个: https//serverfault.com/questions/229435/how-to-break-from-infinite-loop-caused-by-php-script-running-as-root

For future, make sure to have some secure file lock for the script: 为了将来,请确保为脚本提供一些安全的文件锁定:

while(true)  //script loop
{
   if(file_exists("STOP")) {
     unlink("STOP");
     exit;
   }
   /*Do some work*/

} }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM