【发布时间】:2011-11-03 20:09:17
【问题描述】:
出于好奇,我想知道是否可以编写 bash 脚本来记录在 Bash/SSH 会话中运行的所有命令。我知道history 应该记录所有运行的命令,但它似乎非常不可靠!
今天早上我一直在搞砸,想出了以下 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
有谁知道比history更可靠地记录命令的任何东西
干杯
【问题讨论】:
标签: linux bash logging terminal