mirror of
https://github.com/captn3m0/Scripts.git
synced 2024-09-29 22:04:01 +00:00
21 lines
563 B
Plaintext
21 lines
563 B
Plaintext
|
#!/bin/bash
|
||
|
|
||
|
cpwpids=(`ps -ef | grep $USER | grep 'cpw' | grep -v grep | grep -v $$ | awk '{ print $2 }'`) #build an array of all cpw procs for this user that aren't this one.
|
||
|
|
||
|
cpwcnt=${#cpwpids[@]} # number of elemenets in the above array
|
||
|
cnt=$cpwcnt # counter to be decremented each pass
|
||
|
while [ $cnt -gt 0 ]
|
||
|
do
|
||
|
cnt=$cpwcnt
|
||
|
for i in "${cpwpids[@]}" # check if each pid has died yet
|
||
|
do
|
||
|
ps --pid $i >/dev/null
|
||
|
if [ $? -gt 0 ]
|
||
|
then
|
||
|
let "cnt -= 1"
|
||
|
fi
|
||
|
done
|
||
|
sleep 2
|
||
|
done
|
||
|
cp -v "$@" >> /tmp/cpw.log #log
|