1. put the following content to the end of/etc/profile (some systems such as CentOS5.5 may need to end with/etc/bashrc) HISTFILESIZE = 2000 HISTSIZE = 2000 exportHISTTIMEFORMAT = "% Y % m % d-% H % M % S:" exportPROMPT_COMMAND = '{command = $(history1 | {readxy; echo $ y ;}
1. put the following content to the end of/etc/profile (some systems such as CentOS 5.5 may need to end with/etc/bashrc)
HISTFILESIZE=2000HISTSIZE=2000exportHISTTIMEFORMAT="%Y%m%d-%H%M%S:"exportPROMPT_COMMAND='{ command=$(history1 | { readx y; echo$y; } | cut-d ":"-f2-);logger -p local1.notice -t bash"$command(user=$USER,ppid=$PPID,from=$SSH_CLIENT,pwd=$PWD)"; }'readonlyPROMPT_COMMAND
Note: readonly PROMPT_COMMAND prevents malicious normal users from clearing the variables after logging on, resulting in failure to record logs.
2. log output to a single file
Add/etc/rsyslog. conf
local1.notice /var/log/local1
3. configure logrotate
Vim/etc/logrotate. d/local1
/var/log/local1{missingoknotifemptysize 1Myearlycreate 0600 root root}