# man 5 /usr/share/man/man5/systemd-system.conf.5.gz # man 5 /usr/share/man/man5/systemd-user.conf.5.gz
DESCRIPTION When run as a system instance, systemd interprets the configuration file system.conf and the files in system.conf.d directories; when run as a user instance, systemd interprets the configuration file user.conf and the files in user.conf.d directories. These configuration files contain a few settings controlling basic manager operations. See systemd.syntax(5) for a general description of the syntax.
和登陆行为的强关联 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,
systemd offers users the ability to manage services under the user’s control with a per-user systemd instance, enabling users to start, stop, enable, and disable their own units. https://wiki.archlinux.org/title/Systemd/User
[myapp@localhost ~]$ cat /proc/1169/limits Limit Soft Limit Hard Limit Units Max cpu time unlimited unlimited seconds Max file size unlimited unlimited bytes Max data size unlimited unlimited bytes Max stack size 8388608 unlimited bytes Max core file size unlimited unlimited bytes Max resident set unlimited unlimited bytes Max processes 14603 14603 processes Max open files 1024 262144 files Max locked memory 65536 65536 bytes Max address space unlimited unlimited bytes Max file locks unlimited unlimited locks Max pending signals 14603 14603 signals Max msgqueue size 819200 819200 bytes Max nice priority 0 0 Max realtime priority 0 0 Max realtime timeout unlimited unlimited us
[root@rhel8 ] # systemctl daemon-reexec [myapp@rhel8 ~]$ export XDG_RUNTIME_DIR=/run/user/$(id -u) [myapp@rhel8 ~]$ systemctl daemon-reexec --user [myapp@rhel8 ~]$ systemctl --user status myapp ● myapp.service - My demo application Loaded: loaded (/home/myapp/.config/systemd/user/myapp.service; static; vendor preset: enabled) Active: active (running) since Wed 2022-02-16 04:27:33 PST; 5min ago Main PID: 3943 (python3) CGroup: /user.slice/user-1001.slice/user@1001.service/myapp.service └─3943 /usr/bin/python3 -m http.server 8080
不一会儿
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
[myapp@rhel8 ~]$ cat /proc/3943/limits Limit Soft Limit Hard Limit Units Max cpu time unlimited unlimited seconds Max file size unlimited unlimited bytes Max data size unlimited unlimited bytes Max stack size 8388608 unlimited bytes Max core file size unlimited unlimited bytes Max resident set unlimited unlimited bytes Max processes 14603 14603 processes Max open files 65535 65535 files Max locked memory 65536 65536 bytes Max address space unlimited unlimited bytes Max file locks unlimited unlimited locks Max pending signals 14603 14603 signals Max msgqueue size 819200 819200 bytes Max nice priority 0 0 Max realtime priority 0 0 Max realtime timeout unlimited unlimited us