大佬教程收集整理的这篇文章主要介绍了linux – Bash命令记录器,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我今天早上一直在搞乱,并提出了以下bash脚本,它记录了用户在终端中运行的内容,但没有正确运行所有命令.
prompt_read() { echo -n “$(whoami)@$(hostName):$(pwd)~$“ read userinput } prompt_read while :; do if [[ $userinput != exit ]]; then logger "logit $userinput" bash -c "$userinput" prompt_read else kill -1 $PPID fi done
是否有人知道任何记录命令比历史记录更好,更可靠的东西
干杯
HISTFILESIZE=10000 # how many lines of history to store in the history file HISTSIZE=10000 # how many lines of history to store in a session ( I think ) HISTCONTROL=ignoredups # ignore duplicate commands shopt -s histappend # append history,rather than having sessions obliterate exisTing history PROMPT_COMMAND="history -a;$PROMPT_COMMAND"
最后几个是重要的,将PROMPT_COMMAND设置为历史记录 – 会立即追加历史记录,而不是会话后追加.并设置shopt -s histappend将使bash会话附加到历史文件,而不是覆盖现有的历史记录.
更多信息:http://linuxcommando.blogspot.com/2007/11/keeping-command-history-across-multiple.html
以上是大佬教程为你收集整理的linux – Bash命令记录器全部内容,希望文章能够帮你解决linux – Bash命令记录器所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。