Kill running php script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Kill running php script

Post by anjanesh »

Hi

I got a php script that went into an infinite loop and the time limit was set to 0 - I got access to shell - is there any way to kill that running script ?

Thanks
bdlang
Forum Contributor
Posts: 395
Joined: Tue May 16, 2006 8:46 pm
Location: Ventura, CA US

Post by bdlang »

Are you a system admin on the server? If so, you'd have to kill the running HTTPD process, e.g.

Code: Select all

for pid in `ps -axc | grep 'httpd' | awk '{print $1}'`; do kill -HUP $pid; done
or substitute 'apache' for 'httpd' in the above statement, OR find the init script and do a 'restart'
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Nope, Im a user on a shared host with SSH access
bdlang
Forum Contributor
Posts: 395
Joined: Tue May 16, 2006 8:46 pm
Location: Ventura, CA US

Post by bdlang »

Well, unfortunately you'll have to contact your sysadmin (although if they're good they've spotted the issue already and dealt with it).

FYI, you can set 'max_execution_time' in your scripts with ini_set().
User avatar
anjanesh
DevNet Resident
Posts: 1679
Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India

Post by anjanesh »

Accidentaly I had the line set_time_limit(0); !
Post Reply