我想你可以做这样的事情:
服务器.txt
server1
server2
server3
server4
serverA
serverB
raspi10
raspi11
raspi12
raspi13
supercomputerA
supercomputerB
工作.txt
job1
job2
job3
job4
job5
job6
然后使用这个bash
脚本:
#!/bin/bash
# Read in list of jobs into array
jobs=( $(<jobs.txt) )
# Get randomised list of servers
servers=( $( gshuf servers.txt) )
# Assign each job to a server and execute in parallel
for ((i==0;i<${#jobs[@]};i++)) ; do
echo "ssh \"${servers[i]}\" \"${jobs[i]}\""
done | parallel
例子
这会为GNU Parallel生成以下输入:
ssh "raspi12" "job1"
ssh "serverA" "job2"
ssh "serverB" "job3"
ssh "raspi13" "job4"
ssh "server3" "job5"
ssh "supercomputerB" "job6"
备注:
gshuf
是如何GNU shuf
在 Mac 上安装 (shuffle) 的。它可能被称为shuf
在其他机器上。