rm -rvf /tmp/lock
ls test/ | grep "sam[0-9]*" | tee /tmp/sam
proc()
{
if [ `ps aux | egrep -v 'watch|top|grep' | grep -i $0 | wc -l` -le 5 ]
then
$1 &
fi
}
funct()
{
until [ -e /tmp/lock ]
do
touch /tmp/lock
for i in `cat /tmp/sam`
do
cp -rvf test/$i test2/
sed -i "/$i/d" /tmp/sam
sleep 2
rm -rvf /tmp/lock
done
done
}
empt()
{
if [ `cat /tmp/sam | wc -l` -eq 0 ]
then
exit
fi
}
cat /tmp/sam | while read a
do
proc funct&
sleep 2
empt
done
ls test/ | grep "sam[0-9]*" | tee /tmp/sam
proc()
{
if [ `ps aux | egrep -v 'watch|top|grep' | grep -i $0 | wc -l` -le 5 ]
then
$1 &
fi
}
funct()
{
until [ -e /tmp/lock ]
do
touch /tmp/lock
for i in `cat /tmp/sam`
do
cp -rvf test/$i test2/
sed -i "/$i/d" /tmp/sam
sleep 2
rm -rvf /tmp/lock
done
done
}
empt()
{
if [ `cat /tmp/sam | wc -l` -eq 0 ]
then
exit
fi
}
cat /tmp/sam | while read a
do
proc funct&
sleep 2
empt
done
No comments:
Post a Comment