AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题

问题[systemd](unix)

Martin Hope
user19315471
Asked: 2025-04-07 03:53:43 +0800 CST

hostnamectl:固件年龄的来源

  • 11

当我运行hostnamectl命令时,我得到以下输出:

$ hostnamectl 
 Static hostname: myhostname
       Icon name: computer-desktop
         Chassis: desktop 🖥
      Machine ID: 12345e09a3a2464689c345fe7b12345f
         Boot ID: 123451b9f31ff4c166f8368c1f86666ad
Operating System: openSUSE Leap 15.6              
     CPE OS Name: cpe:/o:opensuse:leap:15.6
          Kernel: Linux 6.4.0-150600.23.33-default
    Architecture: x86-64
 Hardware Vendor: ASRock
  Hardware Model: B450 Pro4 R2.0
Firmware Version: P5.60
   Firmware Date: Thu 2022-10-20
    Firmware Age: 2y 5month 2w 3d  <<<<<<<<<< this

我想知道:这个值是Firmware Age从哪里来的?我不知道还有其他命令可以返回这个值。hostnamectl这个值是如何以及从哪里获取的?

systemd
  • 3 个回答
  • 199 Views
Martin Hope
BaRud
Asked: 2025-04-01 00:13:28 +0800 CST

rclone 的“systemctl --user start”失败:用户总线连接问题

  • 5

我已经创建了一个service文件:

cat ~/.config/systemd/user/rclonegdrive.service 
[Unit]
Description=Rclone mound Google Drive
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
ExecStart=/usr/bin/rclone mount gdrive: /home/rudra/Desktop/Zotero
TimeoutSec=5
Restart=on-failure
RestartSec=1
ExecStop=/usr/bin/fusermount -u /home/rudra/Desktop/Zotero
# logs to the journal directly, suppress double logging

[Install]
WantedBy=default.target

但是,它不能与 systemctl 一起使用:

systemctl --user start rclonegdrive.service
Failed to connect to user scope bus via local transport: Connection refused

这是我的systemd/user内容

tree ~/.config/systemd/user/
/home/rudra/.config/systemd/user/
├── default.target.wants
│   └── [email protected] -> /usr/lib/systemd/user/[email protected]
└── rclonegdrive.service

请问有什么帮助吗?

systemd
  • 1 个回答
  • 31 Views
Martin Hope
Adrián Bíro
Asked: 2025-03-29 18:54:53 +0800 CST

systemd 日志指令将“ ^M ”附加到日志文件,我应该在单元文件中指定什么来删除它?

  • 5

我正在运行一个备份脚本(rsync 包装器),--log-file之前我在 rsync 中使用了标志,在切换到StandardOutput/StandardError后,systemd 开始在日志行之间附加“ ^M ”。请问我该如何使用单元文件指令将其删除?

[Unit]
Description=...
Wants=...

[Service]
Type=oneshot
User=adrian
Group=adrian
ReadOnlyPaths=/
ReadWritePaths=/var/log/foo.log
StandardOutput=append:/var/log/foo.log
StandardError=append:/var/log/foo.log
ExecPaths=/usr/local/bin /usr/bin /bin
ExecStart=/usr/local/bin/foo_script.sh

[Install]
WantedBy=multi-user.target

环境设置

echo $LANG
en_US.UTF-8

我尝试了多种输出模式,但结果相同。

这不是由编辑器或其他工具引起的,而是 systemd loggin 正在附加它。使用 rsync 标志在脚本中指定日志记录的原始版本工作正常。journalctl -u <service name>渲染正常,但 systemd 输出指令正在将其附加在那里。

systemd
  • 1 个回答
  • 61 Views
Martin Hope
PersianGulf
Asked: 2025-03-27 03:18:39 +0800 CST

将 DNS 查询路由到我的隧道

  • 5

我有以下系统:

root@debian:~# dpkg -l systemd-resolved
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name             Version      Architecture Description
+++-================-============-============-=================================
ii  systemd-resolved 257.4-3      amd64        systemd DNS resolver
root@debian:~# cat /etc/issue
Debian GNU/Linux trixie/sid \n \l

root@debian:~# ls -l /etc/resolv.conf
lrwxrwxrwx 1 root root 39 Mar 26 20:21 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf

root@debian:~# cat /run/systemd/resolve/stub-resolv.conf 
# This is /run/systemd/resolve/stub-resolv.conf managed by man:systemd-resolved(8).
# Do not edit.
#
# This file might be symlinked as /etc/resolv.conf. If you're looking at
# /etc/resolv.conf and seeing this text, you have followed the symlink.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs should typically not access this file directly, but only
# through the symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a
# different way, replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0 trust-ad
search .

然后我安装了Zebedee隧道,它工作正常。
当我设置firefox开启时localhost:81,我对网站的访问被过滤了。

root@debian:~# telnet localhost 81
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

现在我想使用 DNS over localhost:81。
我该怎么做?

更新: 我的resolvectl是:

root@debian:~# resolvectl status
Global
         Protocols: +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported
  resolv.conf mode: stub
       DNS Servers: 8.8.8.8

Link 2 (enp0s31f6)
    Current Scopes: LLMNR/IPv4 mDNS/IPv4
         Protocols: -DefaultRoute +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported
     Default Route: no

Link 3 (wlp58s0)
    Current Scopes: none
         Protocols: -DefaultRoute +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported
     Default Route: no

Link 5 (docker0)
    Current Scopes: none
         Protocols: -DefaultRoute +LLMNR +mDNS -DNSOverTLS DNSSEC=no/unsupported
     Default Route: no
systemd
  • 1 个回答
  • 19 Views
Martin Hope
Aleksey
Asked: 2025-03-26 15:27:26 +0800 CST

如何通过 systemctl 列出仅处于“禁用”预设的服务?

  • 7

我想知道哪些服务不会随系统启动自动启动,因为PRESET模式是disabled通过systemctl list-unit-files。

两个命令都会产生错误消息:

systemctl list-unit-files --no-pager --preset=disabled
systemctl list-unit-files --no-pager --preset-mode=disabled

错误信息:

Failed to parse preset mode: disabled.
systemd
  • 2 个回答
  • 71 Views
Martin Hope
metablaster
Asked: 2025-03-15 20:16:56 +0800 CST

清理(​​删除)对丢失的 systemd 单元的引用是否安全?

  • 5

列出缺失的服务

systemctl --state=not-found --all

输出:

      UNIT                           LOAD      ACTIVE   SUB  DESCRIPTION                   
● boot.automount                 not-found inactive dead boot.automount                
● home.mount                     not-found inactive dead home.mount
● tmp.mount                      not-found inactive dead tmp.mount                     
● connman.service                not-found inactive dead connman.service
● console-screen.service         not-found inactive dead console-screen.service
● dpdk.service                   not-found inactive dead dpdk.service
● fcoe.service                   not-found inactive dead fcoe.service
● firewalld.service              not-found inactive dead firewalld.service
● haveged.service                not-found inactive dead haveged.service
● ip6tables.service              not-found inactive dead ip6tables.service
● iptables.service               not-found inactive dead iptables.service
● iscsi-shutdown.service         not-found inactive dead iscsi-shutdown.service
● iscsi.service                  not-found inactive dead iscsi.service
● iscsid.service                 not-found inactive dead iscsid.service
● kbd.service                    not-found inactive dead kbd.service
● rbdmap.service                 not-found inactive dead rbdmap.service
● systemd-hwdb-update.service    not-found inactive dead systemd-hwdb-update.service
● systemd-oomd.service           not-found inactive dead systemd-oomd.service
● systemd-update-done.service    not-found inactive dead systemd-update-done.service
● systemd-vconsole-setup.service not-found inactive dead systemd-vconsole-setup.service
● xencommons.service             not-found inactive dead xencommons.service
● xendomains.service             not-found inactive dead xendomains.service            
● virtlxcd.socket                not-found inactive dead virtlxcd.socket
● virtqemud.socket               not-found inactive dead virtqemud.socket
● virtvboxd.socket               not-found inactive dead virtvboxd.socket
● virtvzd.socket                 not-found inactive dead virtvzd.socket
● virtxend.socket                not-found inactive dead virtxend.socket

查找引用缺失服务的单元

grep -rR "<service_name>" /usr/lib/systemd
grep -rR "<service_name>" /etc/systemd

# See tables in man page for more directories to search with grep and to learn their purpose
man systemd.unit

样品tmp.mount

grep -rR "tmp.mount" /usr/lib/systemd
grep -rR "tmp.mount" /etc/systemd

输出:

/usr/lib/systemd/system/basic.target:After=sysinit.target sockets.target paths.target slices.target tmp.mount
/usr/lib/systemd/system/basic.target:Wants=tmp.mount

清理引用

sudo nano /usr/lib/systemd/system/basic.target

内容:

[Unit]
Description=Basic System
Documentation=man:systemd.special(7)
Requires=sysinit.target
Wants=sockets.target timers.target paths.target slices.target
After=sysinit.target sockets.target paths.target slices.target tmp.mount

RequiresMountsFor=/var /var/tmp
Wants=tmp.mount

在这里我们发现tmp.mount了After=Wants=

我想删除这些条目以便systemctl --state=not-found --all不再列出它,对于每个缺失的单元也是如此。

问题

删除系统上每个缺失单元的此类条目是否安全?

systemd
  • 1 个回答
  • 34 Views
Martin Hope
Stewart
Asked: 2025-03-04 19:20:35 +0800 CST

systemd 的 oom-kill 结果是否反映“不干净的信号”或“不干净的退出代码”?

  • 6

我的一项服务最近因 而停止运行oom-kill。

$ systemctl status my-server.service
● my-server.service - "General purposes load-independent HTTP server"
     Loaded: loaded (/lib/systemd/system/my-server.service; enabled; vendor preset: enabled)
     Active: failed (Result: oom-kill) since Thu 2025-02-27 12:47:44 CST; 17h ago
    Process: 636 ExecStart=/usr/bin/my-server --listen-http :13668 --threads 10 (code=exited, status=0/SUCCESS)
   Main PID: 636 (code=exited, status=0/SUCCESS)
        CPU: 52min 57.893s

Feb 27 12:47:44 ios systemd[1]: my-server.service: A process of this unit has been killed by the OOM killer.
Feb 27 12:47:44 ios my-server[636]: Received signal to stop (15). Stopping...
Feb 27 12:47:44 ios systemd[1]: my-server.service: Failed with result 'oom-kill'.
Feb 27 12:47:44 ios systemd[1]: my-server.service: Consumed 52min 57.893s CPU time.

man systemd.exec当“服务进程被内存不足(OOM)终止程序终止”时,表示$SERVICE_RESULT设置为“服务进程被内存不足(OOM)终止程序终止”。oom-kill

这是 的长期运行子进程中发生的内存泄漏/usr/bin/my-server。发生这种情况时,我希望Restart=服务能够正常运行。

问题:

是否$SERVICE_RESULT=oom-kill触发不干净的退出代码,或者不干净的信号?

我想Restart=尽可能地限制自己。因此,我想oom-kill从以下列表中选择符合条件的第一个条件:

  • Restart=on-abort如果它是一个不干净的信号,则可以使用它。
  • Restart=on-abormal可以用于上述情况,或者如果它触发超时原因,或看门狗原因(可能不适用)。
  • Restart=on-failure适用于上述所有情况,外加不干净的退出代码。
  • Restart=always理论上涵盖一切

从man systemd.service:

Table 2. Exit causes and the effect of the Restart= settings
┌──────────────────────┬────┬────────┬────────────┬────────────┬─────────────┬──────────┬─────────────┐
│Restart settings/Exit │ no │ always │ on-success │ on-failure │ on-abnormal │ on-abort │ on-watchdog │
│causes                │    │        │            │            │             │          │             │
├──────────────────────┼────┼────────┼────────────┼────────────┼─────────────┼──────────┼─────────────┤
│Clean exit code or    │    │ X      │ X          │            │             │          │             │
│signal                │    │        │            │            │             │          │             │
├──────────────────────┼────┼────────┼────────────┼────────────┼─────────────┼──────────┼─────────────┤
│Unclean exit code     │    │ X      │            │ X          │             │          │             │
├──────────────────────┼────┼────────┼────────────┼────────────┼─────────────┼──────────┼─────────────┤
│Unclean signal        │    │ X      │            │ X          │ X           │ X        │             │
├──────────────────────┼────┼────────┼────────────┼────────────┼─────────────┼──────────┼─────────────┤
│Timeout               │    │ X      │            │ X          │ X           │          │             │
├──────────────────────┼────┼────────┼────────────┼────────────┼─────────────┼──────────┼─────────────┤
│Watchdog              │    │ X      │            │ X          │ X           │          │ X           │
└──────────────────────┴────┴────────┴────────────┴────────────┴─────────────┴──────────┴─────────────┘
systemd
  • 1 个回答
  • 27 Views
Martin Hope
Ali Sarbanha
Asked: 2025-02-15 03:23:16 +0800 CST

SpamAssassin 无法通过 Systemd 运行,但可以在 CLI 上运行

  • 5

我正在尝试在我的邮件服务器 (Rocky Linux 9.5) 上设置 SpamAssassin。只是一个基本设置!

这是选项变量/etc/sysconfig/spamassassin:

SPAMDOPTIONS="-d -c -m5 -H --create-prefs --max-children 2 -u spamd -g spamd --socketpath=/var/lib/spamassassin/spamd.sock --socketowner=spamd --socketgroup=spamd --socketmode=0666 -s /var/log/spamd.log --debug"

--debug临时添加

当我使用启动SpamAssassin时systemctl,它会因随机错误而退出,并且systemd会再次重新启动它,我将截断的日志放在下面:

.
.
Fri Feb 14 19:59:03 2025 [2133] info: spamd: server successfully spawned child process, pid 2135
Fri Feb 14 19:59:03 2025 [2133] dbg: prefork: child 2135: entering state 0
Fri Feb 14 19:59:03 2025 [2133] dbg: prefork: new lowest idle kid: none
Fri Feb 14 19:59:03 2025 [2135] dbg: spamd: Privilege de-escalation from user 0 and groups 0
Fri Feb 14 19:59:03 2025 [2135] dbg: spamd: setgid ERRNO is 
Fri Feb 14 19:59:03 2025 [2135] dbg: util: get_user_groups: uid is 98
Fri Feb 14 19:59:03 2025 [2133] info: spamd: server successfully spawned child process, pid 2136
Fri Feb 14 19:59:03 2025 [2133] dbg: prefork: child 2136: entering state 0
Fri Feb 14 19:59:03 2025 [2133] dbg: prefork: new lowest idle kid: none
Fri Feb 14 19:59:03 2025 [2136] dbg: spamd: Privilege de-escalation from user 0 and groups 0
Fri Feb 14 19:59:03 2025 [2136] dbg: spamd: setgid ERRNO is 
Fri Feb 14 19:59:03 2025 [2136] dbg: util: get_user_groups: uid is 98
Fri Feb 14 19:59:03 2025 [2133] info: spamd: server killed by SIGTERM, shutting down
Fri Feb 14 19:59:04 2025 [2137] dbg: logger: successfully added file method
.
.

我决定使用以下命令并spamd从cli前台和守护进程运行,它完美地运行!

sudo -u spamd -- spamd -c -m5 -H --create-prefs --max-children 2 -u spamd -g spamd --socketpath=/var/lib/spamassassin/spamd.sock --socketowner=spamd --socketgroup=spamd --socketmode=0666 -s /var/log/spamd.log --debug

sudo即使没有!它也能正常工作。

有人遇到过与 SpamAssassin 或任何其他服务类似的问题吗?

systemd
  • 1 个回答
  • 16 Views
Martin Hope
Thomas P
Asked: 2025-02-12 23:54:48 +0800 CST

Systemd、PrivateTmp 和 JoinsNamespaceOf

  • 5

我们获得了三项服务PrivateTmp=yes(tomcat、clamd和soffice)。 clamd并soffice已JoinsNamespaceOf=tomcat.service设置。

clamd应该能够读取tomcat写入它的所有内容/tmp,对吗?

有没有可能(例如重新启动服务)导致此连接在运行时中断(例如clamd失去读取能力tomcat's /tmp)?

我如何在运行时验证该连接是否存在(是否仍然有效)?

我尝试使用lsns和lsns NS来查看任何关系,但无法识别任何东西。

systemd
  • 1 个回答
  • 22 Views
Martin Hope
luziferius
Asked: 2025-02-11 22:39:12 +0800 CST

如何在插入 USB 设备时自动启动 GUI 应用程序?

  • 4

我希望每当我插入某个 USB 设备时,自动启动 GUI 应用程序。启动后,该应用程序在前台运行,不应以 root 身份运行。

我怎样才能做到这一点?

在我的特定情况下,每当我插入 Yubikey USB FIDO2/TOTP 硬件令牌时,我都希望运行Yubico Authenticator 。

systemd
  • 1 个回答
  • 34 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    模块 i915 可能缺少固件 /lib/firmware/i915/*

    • 3 个回答
  • Marko Smith

    无法获取 jessie backports 存储库

    • 4 个回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    user12345 无法获取 jessie backports 存储库 2019-03-27 04:39:28 +0800 CST
  • Martin Hope
    Carl 为什么大多数 systemd 示例都包含 WantedBy=multi-user.target? 2019-03-15 11:49:25 +0800 CST
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve