Sometimes it's useful to execute a command after each logout, i.e. to cleanup temporary directories, or to log working hours.
This is the way to make the shell execute the script $HOME/.atexit after each logout:
it that may contain arbitrary shell commands, This is the way to make the shell execute the script $HOME/.atexit after each logout:
1. Insert this line at the beginning of the file
$HOME/.profile:
trap ". $HOME/.atexit" 0
trap ". $HOME/.atexit" 0
2. Create a file named "$HOME/.atexit"
i.e.
$ cat > $HOME/.atexit
# echo "Good bye $LOGNAME, the time is `date`"
^D
That's it! After the next login, the shell will execute the contents of the file "$HOME/.atexit".# echo "Good bye $LOGNAME, the time is `date`"
^D
NOTE: this will not work for C-Shell dialects, i.e. TCSH
0 blogger-disqus:
Post a Comment