4.18. Running Commands at Bourne/Korn Shell Logout
describes logout files. Commands in those files are run when you log
out. The Bourne and Korn shells don't have a
logout file, though. Here's how to make one:
In your .profile file, add the line:
trap Section 35.17, . Section 35.29
trap '. $HOME/.sh_logout; exit' 0
(Some systems may need $LOGDIR instead of
Make a file in your home directory named
.sh_logout. Put in the commands you want to be
run when you log out. For example:
35.13, [ -f Section 35.26
if [ -f $HOME/todo.tomorrow ]
echo "=========== STUFF TO DO TOMORROW: ============"
The trap will read the
.sh_logout file when the shell exits.
--JP and SJC
Copyright © 2003 O'Reilly & Associates. All rights reserved.