I am having a shell script, which will start processes and kills the process. It is accepting the processes names as arguments. Need to find the pid
and kill those.
Initially, it was like
for procname in ${@};do
pkill -f $procname
done
Idk why, it is not killing all the processes passed to it. Now, I'm looking something like this
for procname in ${@};do
IFS=$"\n"; echo
(ps auxw | awk -v proc="$procname" -v preserve="${0##*/}" \
'$0 ~ proc && $0 !~ preserve && ! /awk/ { print $2}')
done
I'm trying to print the pid in above code, but I need kill
command and it should be good, if it works without for loop
process names will contains
.
likecom.abc.def.pqr.xyz
$procname