Hello,
According to the manuals, the script .bash_logout is supposed to be executed on exit from a login shell. However, try as I would, I could not make this happen. Can anybody give me some advice?
Regards,
bostjanv
Tried it on a ssh login and it worked fine.
As far as I know bash_logout is only executed when bash is used as a login shell and is not executed for example in graphical logins. Maybe you forgot about this.
Hope this helps
Works for me:
$ cat >~/.bash_logout
echo logging out
^D
$ su -l jdarnold
Password:
$ exit
logout
logging out
$
To the OP, if what you wanted was to execute something when exiting a shell, login or not, what you want is to set a trap on the pseudo-signal 0, or EXIT. Either of
trap ‘echo arrgh!’ 0
trap ‘echo goodbye cruel world’ EXIT
will do what you want. That command can be any valid command or shell script of course.
Hello,
Thanks for your posts. In fact, yes, my intention was to perform some action on exit from the graphical shell, and I mistakenly believed that it was somehow identical to a bash login shell. I later checked that a bash login shell behaves correctly (i.e., it executes .bash_logout if it exists), and I solved my problem as suggested in the previous post.
Regards,
bostjanv