|
|
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' 0A 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.