shellAPP

时间:2021-01-07 21:33:21

1,linux操作日志记录,记录从各个ip登陆到系统的账号,指向命令及命令执行时间

#!/bin/bash
echo "export PROMPT_COMMAND='{ msg=\$(history 1 | { read x y; echo \$y; }); logger -p local5.info \"\$HOSTNAME [HIST] : \$SSH_CLIENT : \$PWD : \$msg\"; }'" >> /etc/bashrc
echo export HISTTIMEFORMAT=\"[%F %T]\" >> /etc/bashrc
echo \# Save user log  >> /etc/rsyslog.conf
echo local5.*             /var/log/hist.log >> /etc/rsyslog.conf
service rsyslog restart

shellAPP

相关文章