리눅스 터미널 종료 시 기록되도록 할수 있을까요?

tingyoon의 이미지

안녕하세요.
Centos7.5 에서 터미널로 접속 기록과 종료 기록을 파일로 남기려고 하는데요

터미널 접속 시에는 /etc/profile에 [export HISTFILE=history.log] 설정을 하여 기록하고 있습니다.

/etc/profile 처럼 혹시 터미널 종료 시에도 작동하게 되는 스크립트가 있을까요?

Hodong Kim@Google의 이미지

아마 특별한 설정없이 자동으로 기록이 남을 겁니다.
last, lastlog, utmp 에 대해 알아보시면 되겠습니다.

https://en.wikipedia.org/wiki/Utmp

익명 사용자의 이미지

~/.bash_logout 이 있기는 합니다. 로그인 쉘에서 동작합니다.

       /etc/profile
              The systemwide initialization file, executed for login shells
       ~/.bash_profile
              The personal initialization file, executed for login shells
       ~/.bashrc
              The individual per-interactive-shell startup file
       ~/.bash_logout
              The individual login shell cleanup file, executed when a login shell exits
       ~/.inputrc
              Individual readline initialization file