Stopping an infinite loop on a remote server PHP

2019-02-08 12:51发布

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?

3条回答
Animai°情兽
2楼-- · 2019-02-08 12:54

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.

查看更多
来,给爷笑一个
3楼-- · 2019-02-08 12:59

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
查看更多
手持菜刀,她持情操
4楼-- · 2019-02-08 13:15

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 ;-)

查看更多
登录 后发表回答