Show Table of Contents
3.5.6. 以批模式使用管理 CLI
介绍
批处理允许大量的操作请求按序列进行分组,然后作为一个单元来执行。如果序列里的任何以一个操作请求执行失败,整个操作组都将回滚。
过程 3.11. 批处理模式命令和操作
启用批处理模式
用batch命令启用批处理模式。[standalone@localhost:9999 /] batch [standalone@localhost:9999 / #]
提示里的井号(#)指明了批处理模式添加操作请求到批处理命令里
在批处理模式下,照常输入操作请求。操作请求将按输入的顺序添加到批处理命令里。关于格式化操作请求的详情,请参考 第 3.5.8 节 “在管理 CLI 里使用操作和命令”。运行批处理命令
一旦输入了整个操作请求序列,请用run-batch运行这个批处理命令。[standalone@localhost:9999 / #] run-batch The batch executed successfully.
关于可用于批处理的完整的命令列表,请参考 第 3.5.7 节 “CLI 批处理模式命令”。保存在外部文件里的批命令
频繁运行的批处理命令可以存储在外部文件里,通过将完整文件路径作为参数传入batch或直接作为run-batch命令的参数来执行。您可以用文本编辑器创建批处理命令文件。每个命令都必须单独一行且 CLI 应该可以访问它。下面的命令将加载myscript.txt文件至批处理模式。这个文件里的所有命令都可以编辑或删除,您也可以插入新的命令。这个批处理会话里进行的修改不会持久化到myscript.txt文件里。[standalone@localhost:9999 /] batch --file=myscript.txt
下面的命令将立即运行存储在文件myscript.txt里的批命令[standalone@localhost:9999 /] run-batch --file=myscript.txt
结果
输入的操作请求序列以批模式完成了。

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.