Tuesday, March 5, 2013

How could you run commands/scripts when you log out session in UNIX?

Run commands/scripts when you log out by appending required lines to the ".logout" file in your HOME directory.

sh shell : ~/.sh_logout
bash shell : ~/.bash_logout
ksh shell : ~/.ksh_logout
tcsh / csh : ~/.logout

Next add the below line to your ".profile" file :
trap '. $HOME/.sh_logout; exit' 0

No comments :