Linux 中的 batch
命令本身是用于在系统负载较低时执行任务的单机工具,它本身不支持多节点操作。但您可以通过以下几种方式实现多节点批量操作:
pdsh (Parallel Distributed Shell)
pdsh -w node1,node2,node3 "command_to_execute"
clustershell
clush -w node1,node2,node3 "command_to_execute"
for node in node1 node2 node3; do
ssh $node "command_to_execute" &
done
wait
ansible all -i "node1,node2,node3," -m command -a "command_to_execute"
srun -N 3 command_to_execute
如果您需要更具体的解决方案,请提供您的具体使用场景和需求细节。