Alright, so... I'm using Gnome 3, and when I click logout in the top-right corner, it takes FOREVER to log out... If it logs out at all. I don't know what takes it so long, but it's ridiculous. What I want to do is find the script it runs and change it to

pkill -KILL -u $USER

That's what I've been typing into a terminal window to log out lately, because it makes it log out instantly. Not over the course of a year. Any help? I can't find it...

I'm running Arch Linux, if it makes a difference.

Dani AI

Generated

Short answer: was right that putting cleanup into your shell logout file can make the GUI session exit quickly in some setups, but it’s not a general GNOME hook. Bash only reads ~/.bash_logout when an interactive login shell exits — that happens if you started X from a console (startx/xinit) or logged in on a TTY and launched the session from there. Display managers like GDM usually start the session directly and do not invoke a login shell, so ~/.bash_logout is not guaranteed to run for every graphical logout. (man7.org)

GNOME itself waits for registered clients to exit and honors “inhibitors” (apps can request a delay while they save state), so a stubborn app is often the real cause of a slow logout. You can inspect inhibitors and blocks with the systemd tool and, on GNOME, use the session command that skips inhibitors if you want an immediate logout. Example commands to try from a terminal (not repeating the one you already used) are:

systemd-inhibit --list
gnome-session-quit --logout --force

Use the first to see which program is blocking; use the second to force GNOME to end the session. (gnome.pages.gitlab.gnome.org)

If the goal is to run a script reliably at logout, hook into the display manager instead of relying on a shell logout file: GDM runs PostSession scripts (e.g. /etc/gdm3/PostSession/Default), and LightDM has a session-cleanup-script option — both run after the user session ends (note: these run as root and will block the login manager while they run). That is the robust place to call user cleanup or a suid-safe helper if needed. (manpages.org)

If you need an immediate, machine-wide kill of a user’s session, prefer the session-aware tools rather than a blunt, unconditional process kill — for example use the systemd login tool to terminate a user’s sessions. Forcibly killing every process owned by a user risks data loss and other side effects; identify and fix the offending application where possible. (manpages.ubuntu.com)

Summary: editing ~/.bash_logout can work (as you discovered) but only in certain login paths; for reliable logout hooks use your display manager’s PostSession/cleanup hooks, and for immediate termination prefer GNOME/systemd session tools after checking what’s blocking the logout.

Recommended Answers

All 2 Replies

Assuming your account is configured to use bash as the shell, then you need to edit ~/.bash_logout

Ah, thank you very much. This works.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.