ユーザ用ツール

サイト用ツール


サイドバー



最近の更新



Tag Cloud

タグ#
6
10
1
3
1
2
17
7
1
1
6
12
4
1
2
202
1
6
2
7
14
5
1
27
3
3
1
6
1
1
41
1
3
3
1
1
1
1
1
1
24
46
7
9
10
5
10
3
3
2
8
2
2
6
5
1
1
4
9
4
3
3
2
1
8
2
4
1
5
27
2
12
2
3
1
1
2
2
1
1
1
4
3
2
4
2
2
1
1
2
1
2
1
2
1
26
2
1
2
2
2
1
1
2
3
13
5
8
1
1
2
12
1
5
1
2
7
1
1
1
1
1
8
1
5
2
1
1
1
3
3
10
1
2
1
1
7
3
1
10
1
1
4
1
2
1
2
7
2
1
3
1
1
3
1
2
1
2
2
2
1
2
3
1
2
3
4
1
3
1
3
3
2
1
1
7
1
3
3
1
1
1
1
5
1
32
2
1
2
1
2
2
3
1
1
1
3
1
2
1
1
1
3
1
1
1
2
4
2
1
1
1
3
1
2
4
2
1
2
1
1
1
1
2
1
1
1
01_linux:99_その他:29_screen_command

29 screenに外からコマンド

複数のscreenを用意しておいて、マルチスレッドで動かす


ZONE="A"
THREAD=10

declare -A ZONES=(
        ["A"]="192.168.10.11"
        ["B"]="192.168.11.11"
        ["C"]="192.168.12.11"
)


i=1;
while [ $i -le $THREAD ]
do
  N=`printf "%02d" "${i}"`
  SCREEN_NAME=${ZONE}-${N}
  LOG="${LOGDIR}/${ZONE}_${N}.log"
  touch $LOG

  i=`expr $i + 1`
  if [ -n "`screen -ls | grep ${SCREEN_NAME}`" ]; then
    echo "already have session_name. ${SCREEN_NAME}"
    continue 2
  fi 
  screen -R ${SCREEN_NAME}
  sleep 1
  screen -d ${SCREEN_NAME}

  screen -S ${SCREEN_NAME} -X logfile "${LOG}"
  sleep 1

  screen -S ${SCREEN_NAME} -X log on
  sleep 1

  if [ "$ZONE" == "main" ];then
    i=`expr $THREAD + 1`
  else
    screen -S ${SCREEN_NAME} -X stuff "ssh root@${ZONES[${ZONE}]}
    "
    sleep 1

    screen -S ${SCREEN_NAME} -X stuff "python3.6
    "
    sleep 1
  fi
01_linux/99_その他/29_screen_command.txt · 最終更新: 2020/07/03 16:11 by matsui

Yesterday:1646 Today:1439 Total:11940