lichaoyue888 发表于 2018-8-23 10:27:47

shell多线程

  shell用rsync同步500G太慢,用iptop看了io还没有满,负载也不是很高,
  因为服务器配置比较高,想起了多线程,
  #!/bin/bash
  cd /data/test/
  thead_num=50
  tmp_fifo_file="/tmp/$$.fifo"
  mkfifo$tmp_fifo_file
  exec4$tmp_fifo_file
  rm -f $tmp_fifo_file
  for((i=0;i&4
  for dir in `ls -F|grep "/"|sed -n '/^/p'|sed 's/\///g'`
  do
  read -u4
  {
  sudo -uwww rsync -avzrtopgL --progress/data/test/$dir test1:/data/test/ >>/data/test5.log
  sleep 3
  echo "">&4
  }&
  done
  wait
  exec 4>&-
  exit 0

页: [1]
查看完整版本: shell多线程