DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Configuring and working with the shells

Adding a logout script

A logout script is a short list of commands that are typically executed when you log out; for example, to issue the clear command to clear your screen, and record the amount of time you spent working.

To create a logout script, edit a file called .logout, enter commands into it, then make it executable with chmod +x .logout. To have it execute automatically when you log out, add the following line to your .profile file (Bourne or Korn shells):

   trap '$HOME/.logout' 0
A typical .logout script might look like the following:
   clear
   banner $LOGNAME "is out"
When you log out by pressing <Ctrl>D or typing exit, you are sending a signal to the shell. A signal notifies the shell that a special event has occurred, and the shell should take action. Several different types of signal are available to the system, but the one you send by logging out is signal 0, called EXIT. (Actually, the <Ctrl>D sends a pseudosignal, but this distinction will be dealt with later.)

See ``Using signals under the UNIX system'' for a detailed explanation of signals and how to use them.

The notation $HOME/.logout is interpreted by the shell; it looks in the variable HOME and substitutes its contents. $HOME is your home directory pathname, so this enables the shell to execute your logout script wherever you are.

Note that if your session is being run in a windows environment, logging out will kill the window as well as the session; in such a case, a logout script may be of no use.


Next topic: Recalling and editing previous commands
Previous topic: Making your prompt tell you where you are

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003