我已经安装、清除并重新安装了 apcupsd 3 次,每次都是这个结果。我在另一台电脑上安装了这个程序,没有问题。顺便说一句,apt 和 aptitude 给出的结果相同。这看起来像是 dpkg 的问题,但我已经没有主意了。出现的第一个错误似乎是谷歌未知的:
Job for apcupsd.service failed because the service did not take the steps required by its unit configuration.
以下是完整的输出....
root@dm:~# aptitude purge apcupsd
The following packages will be REMOVED:
apcupsd{p} apcupsd-doc{u} libusb-0.1-4{u}
0 packages upgraded, 0 newly installed, 3 to remove and 0 not to upgrade.
Need to get 0 B of archives. After unpacking 1,801 kB will be freed.
Do you want to continue? [Y/n/?] y
<snip>
root@dm:~# ps aux | grep apcupsd
root 17003 0.0 0.0 8912 632 pts/1 S+ 14:50 0:00 grep --color=auto apcupsd
root@dm:~# aptitude install apcupsd
The following NEW packages will be installed:
apcupsd apcupsd-doc{a} libusb-0.1-4{a}
0 packages upgraded, 3 newly installed, 0 to remove and 0 not to upgrade.
Need to get 0 B/549 kB of archives. After unpacking 1,801 kB will be used.
Do you want to continue? [Y/n/?]
剪掉
**Setting up apcupsd (3.14.14-3build1) ...
Job for apcupsd.service failed because the service did not take the steps required by its unit configuration.**
See "systemctl status apcupsd.service" and "journalctl -xe" for details.
invoke-rc.d: initscript apcupsd, action "start" failed.
● apcupsd.service - UPS power management daemon
Loaded: loaded (/lib/systemd/system/apcupsd.service; disabled; vendor preset: enabled)
Active: failed (Result: protocol) since Thu 2023-02-16 14:52:25 AEDT; 2ms ago
Docs: man:apcupsd(8)
Process: 17211 ExecStartPre=/lib/apcupsd/prestart (code=exited, status=0/SUCCESS)
Process: 17215 ExecStart=/sbin/apcupsd (code=exited, status=0/SUCCESS)
Tasks: 3 (limit: 38161)
Memory: 724.0K
CGroup: /system.slice/apcupsd.service
└─17216 /sbin/apcupsd
Feb 16 14:52:25 dm systemd[1]: Starting UPS power management daemon...
Feb 16 14:52:25 dm systemd[1]: apcupsd.service: Can't open PID file /run/apcupsd.pid (yet?) after start: Operation not permitted
Feb 16 14:52:25 dm systemd[1]: apcupsd.service: Failed to set a watch for PID file /run/apcupsd.pid: No space left on device
Feb 16 14:52:25 dm systemd[1]: apcupsd.service: Failed with result 'protocol'.
Feb 16 14:52:25 dm systemd[1]: Failed to start UPS power management daemon.
Feb 16 14:52:25 dm apcupsd[17216]: apcupsd 3.14.14 (31 May 2016) debian startup succeeded
Feb 16 14:52:25 dm apcupsd[17216]: NIS server startup succeeded
dpkg: error processing package apcupsd (--configure):
installed apcupsd package post-installation script subprocess returned error exit status 1
Processing triggers for systemd (245.4-4ubuntu3.19) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.9) ...
Errors were encountered while processing:
apcupsd
E: Sub-process /usr/bin/dpkg returned an error code (1)
Setting up apcupsd (3.14.14-3build1) ...
Job for apcupsd.service failed because the service did not take the steps required by its unit configuration.
See "systemctl status apcupsd.service" and "journalctl -xe" for details.
invoke-rc.d: initscript apcupsd, action "start" failed.
● apcupsd.service - UPS power management daemon
Loaded: loaded (/lib/systemd/system/apcupsd.service; disabled; vendor preset: enabled)
Active: failed (Result: protocol) since Thu 2023-02-16 14:52:27 AEDT; 2ms ago
Docs: man:apcupsd(8)
Process: 17509 ExecStartPre=/lib/apcupsd/prestart (code=exited, status=0/SUCCESS)
Process: 17513 ExecStart=/sbin/apcupsd (code=exited, status=0/SUCCESS)
Tasks: 3 (limit: 38161)
Memory: 536.0K
CGroup: /system.slice/apcupsd.service
└─17216 /sbin/apcupsd
Feb 16 14:52:27 dm systemd[1]: apcupsd.service: Found left-over process 17216 (apcupsd) in control group while starting unit. Ignoring.
Feb 16 14:52:27 dm systemd[1]: This usually indicates unclean termination of a previous run, or service implementation deficiencies.
Feb 16 14:52:27 dm systemd[1]: apcupsd.service: Can't open PID file /run/apcupsd.pid (yet?) after start: Operation not permitted
Feb 16 14:52:27 dm systemd[1]: apcupsd.service: Failed to set a watch for PID file /run/apcupsd.pid: No space left on device
Feb 16 14:52:27 dm systemd[1]: apcupsd.service: Failed with result 'protocol'.
Feb 16 14:52:27 dm systemd[1]: Failed to start UPS power management daemon.
Feb 16 14:52:27 dm apcupsd[17514]: Valid lock file for pid=17216, but not ours pid=17514
Feb 16 14:52:27 dm apcupsd[17514]: apcupsd FATAL ERROR in apcupsd.c at line 219
Unable to create UPS lock file.
If apcupsd or apctest is already running,
please stop it and run this program again.
Feb 16 14:52:27 dm apcupsd[17514]: Valid lock file for pid=17216, but not ours pid=17514
Feb 16 14:52:27 dm apcupsd[17514]: apcupsd error shutdown completed
dpkg: error processing package apcupsd (--configure):
installed apcupsd package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
apcupsd
root@dm:~#
答案1
事实证明,只需终止 apt 安装期间启动的进程即可 - 上例中的 pid 17216,但是
$ sudo ps aux | grep apcupsd
会告诉你要杀什么。随后
$ sudo systemctl start apcupsd.service
使一切顺利进行。
问题完全出在安装过程中。安装完成后,它就可以正常工作。我主要不得不忽略大量的错误消息。