服务在 Debian 10 上自动启动

服务在 Debian 10 上自动启动

debian 10我之前在该服务器上安装了带有 的服务器unbound service。今天我注意到该服务每分钟都会重置。我什至手动删除了文件/lib/systemd/system/unbound.service并终止了进程但它又自动运行了;我无法理解哪个进程运行此服务两次。我有两个问题:

#1: 服务如何自动重新启动?

‍#2: 如果服务已经启动了,为什么还要重新设置呢?

我也不认为重置是由于服务本身造成的。

    unbound.service
   Loaded: loaded (/etc/init.d/unbound; generated)
   Active: active (running) since Sun 2022-05-01 14:57:25 +0430; 50s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 24965 ExecStart=/etc/init.d/unbound start (code=exited, status=0/SUCCESS)
 Main PID: 24985 (unbound)
    Tasks: 8 (limit: 4915)
   Memory: 14.3M
   CGroup: /system.slice/unbound.service
                 24985 /usr/sbin/unbound

May 01 14:57:24 INF-dns-ntp02 systemd[1]: Starting unbound.service...
May 01 14:57:24 INF-dns-ntp02 unbound-anchor[24980]: /var/lib/unbound/root.key has content
May 01 14:57:24 INF-dns-ntp02 unbound-anchor[24980]: success: the anchor is ok
May 01 14:57:25 INF-dns-ntp02 unbound[24965]: Starting DNS server: unbound.
May 01 14:57:25 INF-dns-ntp02 systemd[1]: Started unbound.service.

更新:列出文件

/etc/apparmor.d/local/usr.sbin.unbound
/etc/apparmor.d/usr.sbin.unbound
/etc/init.d/unbound
/etc/insserv.conf.d/unbound
/etc/resolvconf/update.d/unbound
/etc/systemd/system/multi-user.target.wants/unbound.service -> /lib/systemd/system/unbound.service
/etc/systemd/system/unbound.service.d
/etc/systemd/system/unbound.service.wants
/etc/systemd/system/unbound.service.wants/unbound-resolvconf.service -> /lib/systemd/system/unbound-resolvconf.service
/etc/unbound
/etc/unbound/unbound.conf
/etc/unbound/unbound.conf.bk
/etc/unbound/unbound.conf.d
/run/systemd/generator.late/graphical.target.wants/unbound.service -> ../unbound.service
/run/systemd/generator.late/multi-user.target.wants/unbound.service -> ../unbound.service
/run/systemd/generator.late/unbound.service
/run/systemd/units/invocation:unbound.service -> ff49954ca79b45bf851f4f6c9eb007da
/usr/lib/x86_64-linux-gnu/libunbound.so.8 -> libunbound.so.8.1.0
/usr/lib/x86_64-linux-gnu/libunbound.so.8.1.0
/usr/sbin/unbound
/usr/sbin/unbound-anchor
/usr/sbin/unbound-checkconf
/usr/sbin/unbound-control
/usr/sbin/unbound-control-setup
/usr/share/doc/libunbound8
/usr/share/doc/unbound
/usr/share/doc/unbound-anchor

更新2: 移除所有/etc/rc*/[ks]unbound

 unbound.service
   Loaded: loaded (/etc/init.d/unbound; generated)
   Active: active (running) since Sun 2022-05-01 18:22:25 +0430; 5s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 4854 ExecStart=/etc/init.d/unbound start (code=exited, status=0/SUCCESS)
 Main PID: 4873 (unbound)
    Tasks: 8 (limit: 4915)
   Memory: 13.6M
   CGroup: /system.slice/unbound.service
                 4873 /usr/sbin/unbound

May 01 18:22:24 INF-dns-ntp02 systemd[1]: Starting unbound.service...
May 01 18:22:25 INF-dns-ntp02 unbound-anchor[4868]: /var/lib/unbound/root.key has content
May 01 18:22:25 INF-dns-ntp02 unbound-anchor[4868]: success: the anchor is ok
May 01 18:22:25 INF-dns-ntp02 unbound[4854]: Starting DNS server: unbound.
May 01 18:22:25 INF-dns-ntp02 systemd[1]: Started unbound.service.

Kill Main PID: 4873 execkill -9 4873 但未绑定的服务会自动再次启动...

更新3: grep -r unbound /etc

output: 

/etc/apparmor.d/usr.sbin.unbound:/usr/sbin/unbound flags=(attach_disconnected) {
/etc/apparmor.d/usr.sbin.unbound:  /etc/unbound/** r,
/etc/apparmor.d/usr.sbin.unbound:  owner /etc/unbound/*.key* rw,
/etc/apparmor.d/usr.sbin.unbound:  audit deny /etc/unbound/unbound_control.{key,pem} rw,
/etc/apparmor.d/usr.sbin.unbound:  audit deny /etc/unbound/unbound_server.key w,
/etc/apparmor.d/usr.sbin.unbound:  /var/lib/unbound/** r,
/etc/apparmor.d/usr.sbin.unbound:  owner /var/lib/unbound/** rw,
/etc/apparmor.d/usr.sbin.unbound:  audit deny /var/lib/unbound/**/unbound_control.{key,pem} rw,
/etc/apparmor.d/usr.sbin.unbound:  audit deny /var/lib/unbound/**/unbound_server.key w,
/etc/apparmor.d/usr.sbin.unbound:  /usr/sbin/unbound mr,
/etc/apparmor.d/usr.sbin.unbound:  /{,var/}run/{unbound/,}unbound.pid rw,
/etc/apparmor.d/usr.sbin.unbound:  /{,var/}run/unbound.ctl rw,
/etc/apparmor.d/usr.sbin.unbound:  #include <local/usr.sbin.unbound>

答案1

可以通过多种方式启动服务。当您运行命令时会显示它们

sudo systemctl status servicname

在“触发者”标题下。

这些都可以单独停止、启动、启用、禁用、屏蔽和取消屏蔽。

另一种服务的示例:

    sudo systemctl status libvirtd.service
● libvirtd.service - Virtualization daemon
     Loaded: loaded (/lib/systemd/system/libvirtd.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2022-04-28 17:26:32 CEST; 2 days ago
TriggeredBy: ● libvirtd-ro.socket
             ● libvirtd-admin.socket
             ● libvirtd.socket
       Docs: man:libvirtd(8)

相关内容