In the below shell script I have list of process ID'sIDs which need to be killed. When killing a process I am getting kill: 1234567: no such process error even after checking if the process id existence using ps -p. Can somebody explain whatWhat could be the reason?
for pid in ${pids[@]}; do
if ps -p $pid > /dev/null; then
kill -9 $pid
fi
done