Capture process id and kill that via script

Dear Experts ,

we have a script scheduled on daily basis ,

cd /u01/oracle/inst/apps/PROD_prodapps/admin/scripts/
./adstpall.sh apps/apps
echo " "
echo " "
echo " "
ps -ef | grep FND
pkill -9 FND
ps -ef | grep FND
pkill -9 FND
ps -ef | grep FND

but even then there are some processes which remain running after executing above script twice and this halts and delays to down oracle database.

then we manually kill these processes and then db is shutdown smoothly.

please tell how we can edit above script to kill processes automatically via some other script.

Regards

---------- Post updated at 02:56 PM ---------- Previous update was at 10:47 AM ----------

how we can store the value of process id in a file and then kill those via pkill etc ?

If all your processes are children of your script, use the PPID to kill them all. If that is not the case, give more details for your request.

store in a file?, use redirection with > or >>