Run script before logout/exit from system

Latest response

Hi
I want a script to be executed when logout is requested. I mean just execute script before actual logout happens.
My script renames old files. It is working script because i've tested it by running.
Through a lot of googling, i came to understand that ~/.bash_logout file will be edited and the command to run script will be written in it. But my linux doesn't have ~/.bash_logout file. It has only ~/.bash_profile which is executed at login. How can i run my script before logout?

Responses