LINUX.ORG.RU

А есть способ убедить systemd не убивать screen при logout?

 ,


2

2

Доброго времени суток

Сабж. screen всю жизнь использовался для возможности запустить долгоиграющий процесс, который не прервется при дисконнекте

Теперь systemd убивает все процессы пользователя при logout. Ну ладно, в этом есть смысл. Но как теперь запустить, чтобы не прибило?

★★★★★

запускаю долгоиграющие процессы через tmux. запустил отконнектился. свободен. даже одно время скрипт был в логине. если есть запущенная сессия грузится в нее, а ежели нет - запускать новую.

pfg ★★★★★
()
Ответ на: комментарий от pfg

Читал топик?

Теперь systemd убивает все процессы пользователя при logout.

screen и tmux выполняют одну и ту же задачу. Только screen на си, а tmux на питоне

Специально проверил, systemd при logout убиват и tmux тоже

З.Ы. насчет питона память подвела, но проблема никуда не исчезнет

router ★★★★★
() автор топика
Последнее исправление: router (всего исправлений: 1)
Ответ на: комментарий от hungry_ewok

Возможно, чо угодно. Главное понимать, зачем.

Ну, и ты такой самоуверенный, видимо, потому, что не пользовался.

Там кроме убиения процессов ещё и /var/run для пользака очищается (а в нем как раз скрин хранит сессии). Менять это, как и конфигурацию systemd, нельзя. Ну, если ты её не поиграться с торрентов украл, а применяешь в реальных условиях, конечно. )

aol ★★★★★
()
Ответ на: комментарий от router

workaround - запускать через ssh.

Чаво? Я уж думал SSH подразумевается в этом случае и изменилось действительно что-то существенное. А так без SSH я долгоиграющее просто запускаю и ничего не закрываю - и оно никуда не отвалится.

А чтобы никто лишний чего не нажал существует блокировка экрана. А делать logout - ну извините вы бы ещё poweroff делали и требовали, чтобы процессы продолжали работать.

unDEFER ★★★★★
()

https://www.freedesktop.org/software/systemd/man/latest/systemd-run.html

Example 5. Start screen as a user service

$ systemd-run --scope --user screen
Running scope as unit run-r14b0047ab6df45bfb45e7786cc839e76.scope.
$ screen -ls
There is a screen on:
        492..laptop     (Detached)
1 Socket in /var/run/screen/S-fatima.

This starts the screen process as a child of the systemd –user process that was started by user@.service, in a scope unit. A systemd.scope(5) unit is used instead of a systemd.service(5) unit, because screen will exit when detaching from the terminal, and a service unit would be terminated. Running screen as a user unit has the advantage that it is not part of the session scope. If KillUserProcesses=yes is configured in logind.conf(5), the default, the session scope will be terminated when the user logs out of that session.

The user@.service is started automatically when the user first logs in, and stays around as long as at least one login session is open. After the user logs out of the last session, user@.service and all services underneath it are terminated. This behavior is the default, when «lingering» is not enabled for that user. Enabling lingering means that user@.service is started automatically during boot, even if the user is not logged in, and that the service is not terminated when the user logs out.

Enabling lingering allows the user to run processes without being logged in, for example to allow screen to persist after the user logs out, even if the session scope is terminated. In the default configuration, users can enable lingering for themselves:

$ loginctl enable-linger
iliyap ★★★★★
()

Чтобы не убивать screen при logout, надо либо не делать logout, либо запускать screen до login. Я делаю detach и выхожу из сессии с помощью exit — screen остается запущенным, без проблем; я что-то делаю не так?

Infra_HDC ★★★★★
()
Ответ на: комментарий от unDEFER

А делать logout - ну извините вы бы ещё poweroff делали и требовали, чтобы процессы продолжали работать.

Ну, для вас, виндузятников, systemd ничего не сломал. Наоборот, принес привычные костыли

router ★★★★★
() автор топика
Ответ на: комментарий от router

Похоже, что сессию без seat пока не убивают

Надеюсь, что и не будут. Иначе придется убивать кроновские джобы, если в этот момент пользователь, от которого запускается джоба, не залогинен, что уже абсурд.

bigbit ★★★★★
()
Ответ на: комментарий от router

там все как то не понятно:

man logind.conf

       KillUserProcesses=
           Takes a boolean argument. Configures whether the processes of a user should be killed when the user logs out. If
           true, the scope unit corresponding to the session and all processes inside that scope will be terminated. If
           false, the scope is "abandoned", see systemd.scope(5), and processes are not killed. Defaults to "no", but see
           the options KillOnlyUsers= and KillExcludeUsers= below.

           In addition to session processes, user process may run under the user manager unit user@.service. Depending on
           the linger settings, this may allow users to run processes independent of their login sessions. See the
           description of enable-linger in loginctl(1).

           Note that setting KillUserProcesses=yes will break tools like screen(1) and tmux(1), unless they are moved out of
           the session scope. See example in systemd-run(1).

Но судя по: systemd-analyze cat-config systemd/logind.conf

У меня как раз дефаульт …

mx__ ★★★★★
()
Ответ на: комментарий от aol

/пожимая плечами/

Я, тащемта, приведенный рецепт использовал на практике, именно с астрой, в режиме шмалянска, запуская долгоиграющий тест в screen через ссш. Работало, скрин жил и тест в нем запущенный исправно крутился пока не отработал.

hungry_ewok
()

man logind.conf

Лучше всего вообще снести systemd, но logind (а если быть точнее, то elogind) все равно практически везде, в слаке с ним половина системы слинкована:

$ ldd /bin/ps 
	linux-vdso.so.1 (0x00007fff13712000)
	libprocps.so.8 => /lib64/libprocps.so.8 (0x00007fc282be5000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00007fc282be0000)
	libc.so.6 => /lib64/libc.so.6 (0x00007fc282a01000)
	libelogind.so.0 => /lib64/libelogind.so.0 (0x00007fc282957000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fc282c47000)
	libcap.so.2 => /lib64/libcap.so.2 (0x00007fc28294a000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fc282929000)
anonymous
()