主要问题:system级别的systemd 服务不能获取诸如logname等的用户信息,需要用户级别的systemd
If you want to take the time to set it up, systemd --user is pretty awesome. I use it to handle just about everything for my user, including X and the i3wm. I don't use a DM, so it just takes me straight to the GUI.
To add to what Trilby is telling you above. To make per user system services, instead of simply adding a User=silentsnake, you could instead use "User=%I" and then rename the service as bt-sync@.service. That way you can enable bt-sync@silentsnake.service as well as bt-sync@wonderwoofy.service and bt-sync@Trilby.service.
[Unit]
Description=BitTorrent Sync service
After=network.target
[Service]
ExecStart=/usr/bin/btsync --nodaemon --config /home/%i/.sync/btsync.conf
Restart=on-abort
User=%i
Group=users
[Install]
WantedBy=multi-user.target
This allows me to run one instance per user with its own configuration. Since it's a server with no users actively working on, I think this is the way to go. But will investigate the systemd user session for my desktop clients.
https://bbs.archlinux.org/viewtopic.php?id=162297
systemctl status
State: degraded
Jobs: 0 queued
Failed: 1 units
CGroup: /
├─user.slice
│ └─user-1000.slice
│ ├─user@1000.service
│ │ ├─gvfs-goa-volume-monitor.service
│ │ │ └─4318 /usr/lib/gvfs/gvfs-goa-volume-monitor
│ │ ├─pulseaudio.service
│ │ │ └─4028 /usr/bin/pulseaudio --daemonize=no
│ │ ├─gvfs-daemon.service
│ │ │ ├─ 4252 /usr/lib/gvfs/gvfsd
│ │ │ ├─ 4257 /usr/lib/gvfs/gvfsd-fuse /run/user/1000/gvfs -f -o big_writes
│ │ │ ├─ 5354 /usr/lib/gvfs/gvfsd-computer --spawner :1.37 /org/gtk/gvfs/exec_spaw/0
│ │ │ ├─16261 /usr/lib/gvfs/gvfsd-trash --spawner :1.37 /org/gtk/gvfs/exec_spaw/1
│ │ │ ├─16275 /usr/lib/gvfs/gvfsd-network --spawner :1.37 /org/gtk/gvfs/exec_spaw/2
│ │ │ └─16309 /usr/lib/gvfs/gvfsd-dnssd --spawner :1.37 /org/gtk/gvfs/exec_spaw/6
│ │ ├─gvfs-udisks2-volume-monitor.service
│ │ │ └─4296 /usr/lib/gvfs/gvfs-udisks2-volume-monitor
│ │ ├─init.scope
│ │ │ ├─3868 /lib/systemd/systemd --user
│ │ │ └─3869 (sd-pam)
│ │ ├─gvfs-gphoto2-volume-monitor.service
│ │ │ └─4314 /usr/lib/gvfs/gvfs-gphoto2-volume-monitor
│ │ ├─at-spi-dbus-bus.service
│ │ │ ├─4182 /usr/lib/at-spi2-core/at-spi-bus-launcher
│ │ │ ├─4187 /usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork --print-address 3
│ │ │ └─4189 /usr/lib/at-spi2-core/at-spi2-registryd --use-gnome-session
│ │ ├─gvfs-metadata.service
│ │ │ └─5429 /usr/lib/gvfs/gvfsd-metadata
│ │ ├─dbus.service
│ │ │ ├─ 3918 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
│ │ │ ├─ 4127 /usr/bin/deepin-wm-dbus
│ │ │ ├─ 4149 /usr/bin/kglobalaccel5
│ │ │ ├─ 4164 /usr/lib/dconf/dconf-service
│ │ │ ├─ 4478 /usr/bin/dman-search
│ │ │ ├─ 5224 /usr/bin/uos-activator
│ │ │ ├─ 5445 /usr/bin/dde-launcher
│ │ │ ├─13606 /usr/lib/x86_64-linux-gnu/gconf/gconfd-2
│ │ │ ├─24394 /usr/bin/dde-control-center
│ │ │ ├─26215 /usr/bin/dde-lock
│ │ │ ├─26280 /usr/bin/python3 /usr/bin/onboard -e --layout Small
│ │ │ └─31303 /usr/bin/deepin-app-store-daemon
│ │ ├─bamfdaemon.service
│ │ │ └─4338 /usr/lib/x86_64-linux-gnu/bamf/bamfdaemon
│ │ ├─gvfs-mtp-volume-monitor.service
│ │ │ └─4323 /usr/lib/gvfs/gvfs-mtp-volume-monitor
│ │ └─gvfs-afc-volume-monitor.service
│ │ └─4308 /usr/lib/gvfs/gvfs-afc-volume-monitor
│ └─session-3.scope
│ ├─ 556 /opt/google/chrome/chrome --type=renderer --field-trial-handle=16083090561268683248,17455005678248332038,131072 --disable-gpu-compositing --lang=zh-CN --origin-trial-disabled-features=Secu
│ ├─ 3483 lightdm --session-child 12 23 24
│ ├─ 3903 /usr/bin/gnome-keyring-daemon --daemonize --login
│ ├─ 3906 /usr/bin/startdde
│ ├─ 3971 /usr/bin/fcitx -d
│ ├─ 3982 /usr/bin/dbus-daemon --syslog --fork --print-pid 5 --print-address 7 --config-file /usr/share/fcitx/dbus/daemon.conf
│ ├─ 3989 /usr/bin/fcitx-dbus-watcher unix:abstract=/tmp/dbus-pLpkQMlYUh,guid=af5ef1dd8eb737d917a0da4160b9835c 3982
│ ├─ 4064 c:\Program Files\WXWork\3.0.23.1604\WXWorkWeb.exe --type=renderer --no-sandbox --client-id=wechat-company --primordial-pipe-token=5395EF03DB774BA21CBCC52774153E64 --user-agent-extra=Mozill
│ ├─ 4111 /usr/lib/deepin-daemon/dde-osd
│ ├─ 4112 /bin/sh /usr/bin/kwin_no_scale
│ ├─ 4123 kwin_x11 -platform dde-kwin-xcb:appFilePath=/usr/bin/kwin_no_scale
│ ├─ 4171 /usr/lib/deepin-daemon/dde-session-daemon
│ ├─ 4197 /usr/bin/dde-dock
│ ├─ 4209 /usr/bin/dde-desktop
│ ├─ 4237 /usr/lib/polkit-1-dde/dde-polkit-agent
│ ├─ 4388 /usr/bin/dde-clipboard
│ ├─ 4389 /usr/lib/geoclue-2.0/demos/agent
│ ├─ 4394 /usr/lib/deepin-deepinid-daemon/deepin-deepinid-daemon
│ ├─ 4405 dde-printer -m 1
│ ├─ 4406 /usr/bin/ss-qt5
│ ├─ 4410 /usr/bin/dde-preload
│ ├─ 4411 /usr/bin/DeepinAIAssistant
│ ├─ 4421 /usr/bin/DeepinVoiceWakeuper
│ ├─ 4461 /usr/bin/dde-clipboardloader
│ ├─ 4644 /usr/share/uosbrowser/uosbrowser --type=renderer --field-trial-handle=13707800499165673488,4735604798094921327,131072 --disable-features=HardwareMediaKeyHandling --disable-gpu-compositing
│ ├─ 5361 /usr/bin/dde-file-manager -n computer:///
│ ├─ 5496 /bin/sh -e /usr/bin/deepin-wine5 c:/Program Files/WXWork/WXWork.exe
│ ├─ 5498 c:/Program Files/WXWork/WXWork.exe
│ ├─ 5503 /usr/lib/i386-linux-gnu/deepin-wine5/wineserver.real -p0
│ ├─ 5509 C:\windows\system32\services.exe
│ ├─ 5512 C:\windows\system32\plugplay.exe
│ ├─ 5519 C:\windows\system32\winedevice.exe
│ ├─ 5529 C:\windows\system32\winedevice.exe
│ ├─ 5531 C:\windows\system32\explorer.exe /desktop
│ ├─ 5969 sh -c /opt/apps/org.deepin.chineseime/files/bin/chinime-qim
│ ├─ 5970 /opt/apps/org.deepin.chineseime/files/bin/chinime-qim
│ ├─ 6193 /usr/share/uosbrowser/uosbrowser --type=renderer --field-trial-handle=13707800499165673488,4735604798094921327,131072 --disable-features=HardwareMediaKeyHandling --disable-gpu-compositing
│ ├─ 7527 deepin-movie
│ ├─ 7537 /opt/google/chrome/chrome --type=renderer --field-trial-handle=16083090561268683248,17455005678248332038,131072 --disable-gpu-compositing --lang=zh-CN --origin-trial-disabled-features=Secu
└─system.slice
├─haveged.service
│ └─1125 /usr/sbin/haveged --Foreground --verbose=1 -w 1024
├─apache2.service
│ ├─ 3210 /usr/sbin/apache2 -k start
│ ├─12956 /usr/sbin/apache2 -k start
│ └─12957 /usr/sbin/apache2 -k start
├─containerd.service
│ └─1860 /usr/local/bin/containerd
├─systemd-udevd.service
│ └─342 /lib/systemd/systemd-udevd
├─cron.service
│ └─2816 /usr/sbin/cron -f
├─porting_ci1.service
│ └─1804 /usr/bin/gitlab-runner run --working-directory /home --config /etc/gitlab-runner/config.toml --service porting_ci1 --user gitlab-runner
├─uml-utilities.service
│ └─3310 /usr/bin/uml_switch -unix /var/run/uml-utilities/uml_switch.ctl
├─docker.service
│ └─2695 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
├─polkit.service
│ └─1796 /usr/lib/policykit-1/polkitd --no-debug
├─com.deepin.userexperience.Daemon.service
│ └─1423 /usr/bin/deepin-user-experience-daemon
├─bluetooth.service
│ └─28739 /usr/lib/bluetooth/bluetoothd
├─accounts-daemon.service
│ └─1412 /usr/lib/accountsservice/accounts-daemon
├─lastore-daemon.service
│ └─4359 /usr/bin/lastore-daemon
├─wpa_supplicant.service
│ └─1427 /sbin/wpa_supplicant -u -s -O /run/wpa_supplicant
├─libvirtd.service
│ ├─2822 /usr/sbin/libvirtd
│ ├─3651 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
│ └─3652 /sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/lib/libvirt/libvirt_leaseshelper
├─lightdm.service
│ ├─2840 /usr/sbin/lightdm
│ └─2931 /usr/lib/xdebug/xorgdist/bin/Xorg :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt1 -novtswitch
├─ModemManager.service
│ └─1436 /usr/sbin/ModemManager --filter-policy=strict
├─nmbd.service
│ └─2701 /usr/sbin/nmbd --foreground --no-process-group
├─systemd-journald.service
│ └─324 /lib/systemd/systemd-journald
├─atd.service
│ └─2839 /usr/sbin/atd -f
├─ssh.service
│ └─2542 /usr/sbin/sshd -D
├─exim4.service
│ └─3191 /usr/sbin/exim4 -bd -q30m
├─NetworkManager.service
│ ├─1416 /usr/sbin/NetworkManager --no-daemon
│ └─2671 /sbin/dhclient -d -q -sf /usr/lib/NetworkManager/nm-dhcp-helper -pf /run/dhclient-enp2s0.pid -lf /var/lib/NetworkManager/dhclient-02b80883-c285-49d3-b820-9144544f8fa7-enp2s0.lease -cf /var/li
├─nvidia-persistenced.service
│ └─1431 /usr/bin/nvidia-persistenced --user nvpd
├─deepin-accounts-daemon.service
│ ├─1430 /usr/lib/deepin-daemon/dde-system-daemon
│ └─2427 rfkill event
├─rsyslog.service
│ └─1410 /usr/sbin/rsyslogd -n -iNONE
├─deepin-anything-tool.service
│ ├─2634 /bin/sh /usr/bin/deepin-anything-tool-ionice --dbus
│ └─2637 deepin-anything-tool --dbus
├─license.service
│ └─2700 /usr/lib/deepin-daemon/uos-license-agent
├─alsa-state.service
│ └─1413 /usr/sbin/alsactl -E HOME=/run/alsa -s -n 19 -c rdaemon
├─dde-filemanager-daemon.service
│ └─4506 /usr/bin/dde-file-manager-daemon
├─atopacct.service
│ └─1500 /usr/sbin/atopacctd
├─atop.service
│ └─12816 /usr/bin/atop -R -w /var/log/atop/atop_20210621 600
├─cups.service
│ └─13014 /usr/sbin/cupsd -l
├─upower.service
│ └─6007 /usr/lib/upower/upowerd
├─runsunloginclient.service
│ ├─ 1433 /opt/apps/com.oray.sunlogin.client/files/bin/oray_rundaemon -e bash /opt/apps/com.oray.sunlogin.client/files/scripts/watch.sh
│ └─27844 /opt/apps/com.oray.sunlogin.client/files/bin/sunloginclient --mod=service
├─deepin-elf-verify.service
│ └─1417 /usr/sbin/deepin-elf-verify
├─udisks2.service
│ └─1422 /usr/lib/udisks2/udisksd
├─lastore-smartmirror-daemon.service
│ └─15066 /usr/bin/lastore-smartmirror-daemon
├─smbd.service
│ ├─3201 /usr/sbin/smbd --foreground --no-process-group
│ ├─3305 /usr/sbin/smbd --foreground --no-process-group
│ ├─3306 /usr/sbin/smbd --foreground --no-process-group
│ └─3346 /usr/sbin/smbd --foreground --no-process-group
├─dbus.service
│ ├─1415 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
│ ├─1774 /usr/lib/deepin-deepinid-daemon/deepin-sync-helper
│ ├─1806 /usr/lib/deepin-daemon/backlight_helper
│ └─3425 /usr/lib/deepin-authenticate/deepin-authentication
├─systemd-timesyncd.service
│ └─1124 /lib/systemd/systemd-timesyncd
├─deepin-anything-monitor.service
│ └─23371 /usr/bin/deepin-anything-monitor
├─smartd.service
│ └─1424 /usr/sbin/smartd -n
└─systemd-logind.service
└─1443 /lib/systemd/systemd-logind
https://wiki.archlinux.org/title/Systemd/User
https://nts.strzibny.name/systemd-user-services/
https://linux.cn/article-5926-1.html systemctl 命令完全指南