Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

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

I'm reading The Unix Programming Environment. There is an exercise question to print how much CPU time you have consumed when you log off by editing .profile.

I tried with this

trap 'times' 0 1 2 15

but it is not working.

share|improve this question

In bash, the ~/.bash_logout file will be executed upon exiting a login shell. Put your code in that file.

share|improve this answer

From the tag, I'm guessing that this is in bash. Bash defaults to .bash_profile and only uses .profile if the former does not exists. Try putting the trap line in .bash_profile.

Alternatively, you could put the following in .bash_logout:

read -t 5 # timeout after 5 seconds
share|improve this answer

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.