mirror of https://github.com/captn3m0/Scripts.git
Better file copy program with queues
This commit is contained in:
parent
31304a0839
commit
140121cea2
|
@ -0,0 +1,20 @@
|
||||||
|
#!/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
|
Loading…
Reference in New Issue