Need to run a script after logout on CentOS Linux

I got a shell script named /root/script.bash. When I logout from root account, I need to run a script named /root/script.bash. Is it possible? If so, how?

Edit $HOME/.bash_logout on CentOS 6 Linux i.e. /root/.bash_logout and put the script. For example:

vi /root/.bash_logout

Append the following line:


Save and close the file. Make sure /root/script.bash set with an executable bit. If not set it using chmod:

chmod +x /root/script.bash

That is all. See

Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki