home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 2.16 Approved Shells: Using Unapproved Login Shell Chapter 3 Next: 3.2 Running Commands at Bourne/Korn Shell Logout
 

3. Logging Out

3.1 Running Commands When You Log Out

Is there something you want to do every time you log out: run a program that deletes temporary files, asks you a question, or prints a fortune to your screen? If you use the C shell, make a file named .logout ( 2.2 ) in your home directory and put the commands there. Before a login C shell exits, it'll read that file. But not all shells are login C shells; you might want these shells to read your logout-type file, too. Articles 2.7 and 2.8 have some suggestions.

Some ideas for your .logout are:

  • A command like fortune ( 3.3 ) to give you something fun to think about when you log out.

  • A background command to clean up temporary files, as in article 3.4 .

  • A command to list a "reminder" file - for example, work to take home.

  • A script that prompts you for the hours you've worked on projects so you can make a timesheet later.

  • The command clear ( 22.18 ) to erase your screen. This keeps the next user from reading what you did. [1] It also helps to stop "burn-in" damage to terminals caused by characters left over from your login session. (Some UNIXes clear the screen before printing the login: prompt. Of course, this won't help users who connect with a data switch ( 52.9 ) or port manager because the connection will be broken before the next login prompt.)

    [1] Some terminals and windows have "scroll back" memory of previous screens. clear usually doesn't erase all of that.

If you connect to this host over a network, with a slow modem or on a data switch - and you don't see all the .logout commands run before your connection closes - try putting the command sleep 2 ( 40.2 ) at the end of the file. That makes the shell wait two seconds before it exits, which gives output more time to get to your screen.

- JP


Previous: 2.16 Approved Shells: Using Unapproved Login Shell UNIX Power Tools Next: 3.2 Running Commands at Bourne/Korn Shell Logout
2.16 Approved Shells: Using Unapproved Login Shell Book Index 3.2 Running Commands at Bourne/Korn Shell Logout

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System