赞
踩
关于使用命令 systemctl disable syslog.service
之后, systemctl enable syslog.service
命令失败的问题:
root@backvm-virtual-machine:~# systemctl enable syslog.service
Failed to execute operation: No such file or directory
通过网上查找,看到这么一条信息:
于是尝试执行命令,使用 rsyslog.service:
root@backvm-virtual-machine:~# systemctl enable rsyslog.service
Synchronizing state of rsyslog.service with SysV init with /lib/systemd/systemd-sysv-install...
Executing /lib/systemd/systemd-sysv-install enable rsyslog
Created symlink from /etc/systemd/system/syslog.service to /lib/systemd/system/rsyslog.service.
root@backvm-virtual-machine:~#
查看一下当前系统的syslog.service 服务
root@backvm-virtual-machine:~# ls /etc/systemd/system -l
总用量 100
drwxr-xr-x 2 root root 4096 2月 27 2019 suspend.target.wants
drwxr-xr-x 2 root root 4096 5月 20 2020 sysinit.target.wants
lrwxrwxrwx 1 root root 35 8月 26 23:56 syslog.service -> /lib/systemd/system/rsyslog.service
drwxr-xr-x 2 root root 4096 2月 27 2019 timers.target.wants
root@backvm-virtual-machine:~#
root@backvm-virtual-machine:~#
root@backvm-virtual-machine:~# systemctl status syslog.service
● rsyslog.service - System Logging Service
Loaded: loaded (/lib/systemd/system/rsyslog.service; enabled; vendor preset: enabled)
Active: active (running) since 五 2022-08-26 23:48:31 CST; 58min ago
Docs: man:rsyslogd(8)
http://www.rsyslog.com/doc/
Main PID: 27572 (rsyslogd)
CGroup: /system.slice/rsyslog.service
└─27572 /usr/sbin/rsyslogd -n
8月 26 23:48:30 backvm-virtual-machine systemd[1]: Stopped System Logging Service.
8月 26 23:48:31 backvm-virtual-machine systemd[1]: Starting System Logging Service...
8月 26 23:48:31 backvm-virtual-machine systemd[1]: Started System Logging Service.
root@backvm-virtual-machine:~#
可以看到,syslog.service 指向 /lib/systemd/system/rsyslog.service。
且 syslog.service 服务运行正常。
我们 cat 查看一下 syslog.service 和 rsyslog.service 两个配置文件有什么区别:
root@backvm-virtual-machine:~# systemctl cat syslog.service
# /lib/systemd/system/rsyslog.service
[Unit]
Description=System Logging Service
Requires=syslog.socket
Documentation=man:rsyslogd(8)
Documentation=http://www.rsyslog.com/doc/
[Service]
Type=notify
ExecStart=/usr/sbin/rsyslogd -n
StandardOutput=null
Restart=on-failure
[Install]
WantedBy=multi-user.target
Alias=syslog.service
root@backvm-virtual-machine:~#
root@backvm-virtual-machine:~#
root@backvm-virtual-machine:~# systemctl cat rsyslog.service
# /lib/systemd/system/rsyslog.service
[Unit]
Description=System Logging Service
Requires=syslog.socket
Documentation=man:rsyslogd(8)
Documentation=http://www.rsyslog.com/doc/
[Service]
Type=notify
ExecStart=/usr/sbin/rsyslogd -n
StandardOutput=null
Restart=on-failure
[Install]
WantedBy=multi-user.target
Alias=syslog.service
root@backvm-virtual-machine:~#
通过文件内容,可以看到,原来是 rsyslog.service 指定了别名为:syslog.service。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。