Take the 2-minute tour ×
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.

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
add comment

2 Answers 2

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

share|improve this answer
add comment

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:

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

Your Answer

 
discard

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.