zombie processes are processes that have terminated, but have not had the
wait() system call made for them (to process their error level and finalise removal from the process table).
As a programmer, you are expected to make sure that if your programs spawn children, that the wait() system call is made for them, just like you should always make sure you call close() on file handles.
The shell has a built-in command called "wait", which you could call like this:
Code:
#!/bin/bash
cd /var/www/html/
php somescript.php &
php otherscript.php &
wait
# $? is the return status of the last process "wait"ed for
exit $?
This would make the shell wait until all child processes have finished and will call the wait system call for them.
If you want the script itself to run in the background (so you can close the terminal which you run it from), call it like this:
Code:
nohup shell_script.sh &