开多进程处理:
job_num=10
echo `date` >> 1234.txt
function do_work()
{
sleep 1
echo "Do work.."
}
for ((i=0; i < job_num ;i++)); do
echo "Fork job $i"
(do_work)& (这里的&符号来让该命令在后台执行)
done
wait
echo `date` >> 1234.txt
不开多进程,效率相差十倍...
job_num=10
echo `date` >> 1234.txt
function do_work()
{
sleep 1
echo "Do work.."
}
for ((i=0; i < job_num ;i++)); do
echo "Fork job $i"
do_work)
done
wait
echo `date` >> 1234.txt
阅读(880) | 评论(0) | 转发(0) |