debian lxc - screen killed out logout


Dec 21, 2017
So I've been struggling with this for a few hours and everything I've found online leads to huge arguments about how systemd (back in 2016?) changed a default to kill all user processes on logout. Well that sounds ok, but it kills things like screen. screen has been used for many many years, specifically for the use of keeping something running after you logout.

They say the systemd default is enabled but it's up to distros to pick. Well I'm using a Debian container and it appears to be disabled by default but my screen session still gets killed as soon as I logout.

There have been a few suggestions, none have worked. Is this specific to being in a container?

$ systemd-run --scope --user screen Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=<user> --user to connect to bus of other user) $ systemd-run --scope --user screen Execution in user context is not supported on non-local systems. $ systemd-run --scope --machine=clickwir@.localhost --user screen Execution in user context is not supported on non-local systems. $ systemd-run --scope --machine=clickwir@localhost --user screen Execution in user context is not supported on non-local systems. $ systemd-run --scope --machine=clickwir@ --user ls Execution in user context is not supported on non-local systems. $ loginctl enable-linger Could not enable linger: Connection timed out

It was suggested to add 'export XDG_RUNTIME_DIR=/run/user/$(id -u)' to .bashrc
Well that did result in something different, but still doesn't work.

$ systemd-run --scope --user screen Failed to connect to bus: No such file or directory

I need to have screen continue to run on logout/disconnect. Honestly it's more the ungraceful disconnect I'm concerned with. Just because my desktop system disconnects/dies/locks shouldn't affect screen.
Was talking about this with a co-worker today. To recreate, it should be this simple:

Install Debian bullseye container.
Within that container, install screen.
Run screen.
Within screen, run something like 'top' that will keep running.
Ctrl+A, D to detach screen.
Run 'screen -list'.
Get error 'No Sockets found'
Be sad that screen is broken.

Or maybe it works for you?
Has no one else tried to run screen on a container? This is still a problem. Screen is entirely broken when you logout.
Sadly, I haven't found a solution yet.

IMO, systemd is overstepping it's bounds by a lot. Was meant to be an init system replacement and it's morphed into a lot more than that and is slowly replacing everything in a linux system with a systemd method/application/service/way of life. And I don't really care for it.

This problem being a prime example. Screen is meant to be able to run after you logout and systemd is completely doing away with that and taking a stance that simply doesn't work with how users need a system to function. Especially one they've been using like this for, literally, decades.

That complaint out of the way, I'm considering using Devuan instead. It's a Debian fork but with without systemd. It's been around for a few years and looks like the only way to get back basic functions.

Some more info on Devuan
Is there a solution to this other than using a different fork? In my case it is impacting pm2 also, it just feels super odd to kills such a core function of how linux has worked for decades. Everything works as normal with Ubuntu 20.04 but not 22.04 or 23.04.
I don't know why, but reinstalling sshd fixes the problem.

apt-get install --reinstall openssh-server


The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!