ITPub博客

首页 > 自动化运维 > 应用服务器 > [20210618]记录bash shell执行的命令.txt

[20210618]记录bash shell执行的命令.txt

原创 应用服务器 作者:lfree 时间:2021-06-22 10:01:43 1 删除 编辑

[20210618]记录bash shell执行的命令.txt

--//新版本bash shell加入了记录执行命令的功能,仅仅设置syslog_history.简单测试并记录如下:

# echo $BASH_VERSION
4.2.46(2)-release

# shopt syslog_history
syslog_history  off

# shopt -s syslog_history

# shopt syslog_history
syslog_history  on

--//测试如下:

# pwd
# cd /tmp

Jun 22 08:41:21 xxxx2 -bash: HISTORY: PID=1257 UID=0 shopt syslog_history
Jun 22 08:41:34 xxxx2 -bash: HISTORY: PID=1257 UID=0 pwd
Jun 22 08:41:37 xxxx2 -bash: HISTORY: PID=1257 UID=0 cd /tmp/
Jun 22 08:41:40 xxxx2 systemd-logind: New session 136371 of user root.
Jun 22 08:41:40 xxxx2 systemd: Started Session 136371 of user root.
Jun 22 08:42:38 xxxx2 -bash: HISTORY: PID=1465 UID=0 tail -F /var/log/messages

--//可以将该命令写入/etc/bashrc,这样全部命令在/var/log/messages都会记录下来.
--//另外一个方法使用script,这个可以使用它做一些演示,可以使用scriptreplay回放.
--//参考链接:http://blog.itpub.net/267265/viewspace-1276764/=>[20140922]scriptreplay的使用.txt




来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/267265/viewspace-2777710/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    4006
  • 访问量
    7970354