DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Customizing your environment

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.)

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: If your session is being run in a windows based environment, logging out will kill the window as well as the session; in such a case, a logout script may be of no use.


© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 22 April 2004