is there any way that i can write a script that will kill all current ftp processes, for example if ps -ef | grep ftp produces 3 active proceses, then I would like to somehow extract the PID for each one and pass that to kill -9
has anybody done this before that could give me some ideas
for signal in "-15" "-1" "-9"
do
pids=`ps -ef | grep ftp | awk '{print $2}'`
kill $signal $pids 2> /dev/null
done
This tries to kill the process nicely first, then get's serious!
EDIT: If your OS has it, you could always use the "killall" command instead. Beware on HP-UX 10.20 - the killall command will do just that - kill all processes! On Linux, however, killall sends signals to processes by name.