强大的Linux终端行为记录和回放工具:script命令详解

作家Philip G. Ezolt在其作品<<Optimizing Linux Performance: A Hands On Guide to Linux Performance Tools>>的1.1章节中建议读者在尝试解决Linux问题的时候,将在终端上跑的命令都完整记录下来,以便后续进行问题复现或者是回查。其中还重点推荐了这个script命令,这一节我们来一起看看这到底是个什么命令。

It is better just to record exactly what you typed. You can then reproduce the exact command line for a future test, and when reviewing past results, you can also see exactly what you measured. The Linux command script (described in detail in Chapter 8, “Utility Tools: Performance Tool Helpers”) or “cut and paste” from a terminal is a good way to do this.

我是T型人小付,一位坚持终身学习的互联网从业者。喜欢我的博客欢迎在csdn上关注我,如果有问题欢迎在底下的评论区交流,谢谢。

简单介绍

script命令用来记录终端的行为及结果,并存储成本地文件,可以直接用编辑器打开进行查看。同时可以记录时间轴信息,利用scriptreplay命令进行动态查看。

使用方法详解

利用script -h查看其帮助文档,如下

[root@testmachine ~]# script -h

Usage:
 script [options] [file]

Options:
 -a, --append            append the output
 -c, --command <command> run command rather than interactive shell
 -e, --return            return exit code of the child process
 -f, --flush             run flush after each write
     --force             use output file even when it is a link
 -q, --quiet             be quiet
 -t, --timing[=<file>]   output timing data to stderr (or to FILE)
 -V, --version           output version information and exit
 -h, --help              display this help and exit

常规使用

首先这个命令是可以不接任何参数直接跑的,例如

[root@testmachine ~]# script
Script started
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值