1

I write shell script that runs PHP process. But it was not running in background. Can I kill the shell script without killing the PHP process which is running?

2

Yes, but you have to separate it first. To separate the child from the parent process, run:

kill -20 PID

kill -18 PID

See also: https://stackoverflow.com/questions/625409/how-do-i-put-an-already-running-process-under-nohup

If you are on the same terminal with the process, type ctrl-z to stop the parent, and the use ps -ef to find the PID of the php child. Use the kill lines above to effectively separate the child from the parent. Then fg back into your shell script and it should terminate normally, or you can kill -9 the shell script by PID or name directly while you are at the prompt. Otherwise, killing the parent will (eventually) take out the child.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.