Our world is worth fighting for

—— Mei-Ling Zhou

记一个在systemd 使用中出现的小问题

01 Apr 2017

今天把 systemd service 从system 迁移到了uesr 于是 出现了一个问题, 那就是当登出用户后systemd 会杀死service进程。 多方搜索终于发现了问题所在。

在arch wiki中给出了很好解释 详见https://wiki.archlinux.org/title/Systemd/User

Automatic start-up of systemd user instances:

The systemd user instance is started after the first login of a user and killed after the last session of the user is closed. Sometimes it may be useful to start it right after boot, and keep the systemd user instance running after the last session closes, for instance to have some user process running without any open session. Lingering is used to that effect. Use the following command to enable lingering for specific user:

  loginctl enable-linger username

对就是这么简单。 这就是不仔细看文档的后果。