1

The file ~/.profile can be used to specify commands to run when a user logs in to a session. This has the advantage over ~/.bash_profile in that it works for shells other than bash and also works for at least some desktop environments (e.g. it works for me logging into Mate). However, I am wondering if there is an equivalent to ~/.profile for logging out, which (unlike ~/.bash_logout) will run commands on user logout for other shells as well as the Mate DE?

(note: I tried the obvious ~/.logout and it didn't seem to work)

To clarify, in response to some of the comments:

I am using OpenRC, not systemd, so the answer to this question doesn't help me. This is not in any way a duplicate of that question. I am looking for something that would be independent of the init system and also per user, not system-wide (hence the comparison to ~/.profile).

I think 'no' would be a perfectly acceptable answer, if the answer is 'no' (with perhaps an explanation of what is the 'proper' way to run commands on logout from the DE for a user).

11
  • 1
    Does this answer your question? How to run a script with systemd right before shutdown? Jul 2, 2020 at 1:36
  • What I do in my $HOME/.profile: test -f "$HOME"/.exitrc && trap '. "$HOME/.exitrc"' EXIT
    – Mikel
    Jul 2, 2020 at 3:15
  • @GillesQuenot I am actually using OpenRC, rather than systemd, so unfortunately the answer to that question doesn't help me.
    – Time4Tea
    Jul 2, 2020 at 12:54
  • @Mikel thanks for your suggestion - I will give it a try. So, that suggests the answer to my question may be 'no'?
    – Time4Tea
    Jul 2, 2020 at 12:55
  • @Mikel I tried your suggestion, but it doesn't seem to work for me. The trap doesn't seem to fire, either on user logout or full system reboot.
    – Time4Tea
    Jul 2, 2020 at 16:07

0

You must log in to answer this question.

Browse other questions tagged .