artnikpro
artnikpro

Reputation: 5869

How to stop PHP file execution with exec or shell_exec

I have triggered a PHP file which has an infinite loop, with:

shell_exec('php '.__DIR__.'/serv.php 2>&1 > /dev/null &');

and now I can't to stop it.

Is there any way to do it with 'shell_exec' or 'exec'?

Upvotes: 0

Views: 3105

Answers (2)

Matthew R.
Matthew R.

Reputation: 4350

PHP is a service. You can either run killall php or killall php-cgiin shell or, if you are using a program like MAMP or WAMP, you can simply close and reopen the program. Also, if you are using a later version of PHP there should be infinite loop failsafes. Check your php.ini for max_execution_time to see how long the script should be allowed to run. You can also set this in your file using the set_time_limit function.

Upvotes: 1

schoash
schoash

Reputation: 166

just run the following on your shell

killall php

Upvotes: 0

Related Questions