Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In an attempt to execute a script when a user logs out from a shell session, I added

trap SCRIPT 0 1 2 15;

in .profile..

Why is it not working?

share|improve this question

The different shells run different files on logout - you can execute your script from one of these files, depending on you shell:

  • for bash the file is ~/.bash_logout
  • for tcsh the file is ~/.logout
  • for zsh the file is ~/.zlogout
share|improve this answer
I'm doing this exercise and i have to use .profile and trap – Furqan Oct 5 '11 at 18:13
its from The Unix programming Environment By Robert Pike and Brain W. Kernighan – Furqan Oct 5 '11 at 18:14
@Furqan So what? We are not here to answer exercises. Vladimir's answer is correct and works. – mailq Oct 5 '11 at 19:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.