我是一名 Ubuntu 新手用户,按照本教程在运行 Ubuntu 18.04 的 Mac Mini 4.1 上使用mbpfan启用风扇管理。
我最初取得了很好的成功,然后尝试将mbpfan变成系统服务。我遇到的第一个问题是安装后我的系统上没有 mbpfan.service 文件,所以我只是从 GitHub下载它,通过 SFTP 将它上传到我的下载文件夹,然后按照指示复制它sudo cp mbpfan.service /etc/systemd/system/
。
但这是我尝试执行时的结果sudo systemctl enable mbpfan.service
:
Synchronizing state of mbpfan.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable mbpfan
Failed to enable unit: File mbpfan.service: Invalid argument
我有点卡在这一点上,希望能轻推一下。谢谢你。
= = = = = = = = =
编辑1:
~$ systemctl status mbpfancs.service
出品:
mbpfancs.service - mbpfan Custom Service
Loaded: loaded (/etc/systemd/system/mbpfancs.service; disabled; vendor preset
Active: failed (Result: exit-code) since Sat 2019-09-28 10:57:08 UTC; 27s ago
Process: 8521 ExecStart=/usr/sbin/mbpfan -f (code=exited, status=1/FAILURE)
Main PID: 8521 (code=exited, status=1/FAILURE)
Sep 28 10:57:08 macmini systemd[1]: Starting mbpfan Custom Service...
Sep 28 10:57:08 macmini systemd[1]: mbpfancs.service: Main process exited, code=
Sep 28 10:57:08 macmini systemd[1]: mbpfancs.service: Failed with result 'exit-c
Sep 28 10:57:08 macmini systemd[1]: Failed to start mbpfan Custom Service.`
然后
~$ journalctl -xe
Sep 28 09:10:19 macmini dbus-daemon[1048]: [system] Successfully activated service 'org.freedesktop.hostname1'
Sep 28 09:10:19 macmini systemd[1]: Started Hostname Service.
-- Subject: Unit systemd-hostnamed.service has finished start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit systemd-hostnamed.service has finished starting up.
--
-- The start-up result is RESULT.
Sep 28 09:10:19 macmini hassio-supervisor[9614]: 19-09-28 09:10:19 INFO (MainThread) [hassio.host.services] Update service information
Sep 28 09:10:19 macmini hassio-supervisor[9614]: 19-09-28 09:10:19 INFO (MainThread) [hassio.utils.gdbus] Call org.freedesktop.systemd1.Manager.L
Sep 28 09:17:01 macmini CRON[2158]: pam_unix(cron:session): session opened for user root by (uid=0)
Sep 28 09:17:01 macmini CRON[2159]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Sep 28 09:17:01 macmini CRON[2158]: pam_unix(cron:session): session closed for user root
Sep 28 09:50:53 macmini systemd-timesyncd[548]: Network configuration changed, trying to establish connection.
Sep 28 09:50:53 macmini systemd-timesyncd[548]: Synchronized to time server 91.189.89.198:123 (ntp.ubuntu.com).
Sep 28 10:17:01 macmini CRON[5657]: pam_unix(cron:session): session opened for user root by (uid=0)
Sep 28 10:17:01 macmini CRON[5658]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)
Sep 28 10:17:01 macmini CRON[5657]: pam_unix(cron:session): session closed for user root
Sep 28 10:36:59 macmini hassio-supervisor[9614]: 19-09-28 10:36:59 INFO (MainThread) [hassio.updater] Fetch update data from https://version.home
Sep 28 10:36:59 macmini hassio-supervisor[9614]: 19-09-28 10:36:59 INFO (MainThread) [hassio.store.git] Update add-on https://github.com/home-ass
Sep 28 10:36:59 macmini hassio-supervisor[9614]: 19-09-28 10:36:59 INFO (MainThread) [hassio.store.git] Update add-on https://github.com/danimtb/
Sep 28 10:36:59 macmini hassio-supervisor[9614]: 19-09-28 10:36:59 INFO (MainThread) [hassio.store.git] Update add-on https://github.com/hassio-a
Sep 28 10:37:00 macmini hassio-supervisor[9614]: 19-09-28 10:37:00 INFO (MainThread) [hassio.store] Load add-ons from store: 61 all - 0 new - 0 r
Sep 28 10:56:04 macmini sudo[8465]: grant : TTY=pts/0 ; PWD=/home/grant ; USER=root ; COMMAND=/bin/nano /etc/systemd/system/mbpfancs.service
Sep 28 10:56:04 macmini sudo[8465]: pam_unix(sudo:session): session opened for user root by grant(uid=0)
Sep 28 10:56:49 macmini sudo[8465]: pam_unix(sudo:session): session closed for user root
Sep 28 10:57:08 macmini sudo[8518]: grant : TTY=pts/0 ; PWD=/home/grant ; USER=root ; COMMAND=/bin/systemctl start mbpfancs
Sep 28 10:57:08 macmini sudo[8518]: pam_unix(sudo:session): session opened for user root by grant(uid=0)
Sep 28 10:57:08 macmini systemd[1]: Starting mbpfan Custom Service...
-- Subject: Unit mbpfancs.service has begun start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit mbpfancs.service has begun starting up.
Sep 28 10:57:08 macmini mbpfan[8521]: mbpfan starting up
Sep 28 10:57:08 macmini mbpfan[8521]: A previously created .pid file exists at: /var/run/mbpfan.pid. Aborting
Sep 28 10:57:08 macmini systemd[1]: mbpfancs.service: Main process exited, code=exited, status=1/FAILURE
Sep 28 10:57:08 macmini systemd[1]: mbpfancs.service: Failed with result 'exit-code'.
Sep 28 10:57:08 macmini systemd[1]: Failed to start mbpfan Custom Service.
-- Subject: Unit mbpfancs.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit mbpfancs.service has failed.
--
-- The result is RESULT.
Sep 28 10:57:08 macmini sudo[8518]: pam_unix(sudo:session): session closed for user root
lines 1061-1108/1108 (END)
= = = = = = = = =
编辑2:
~$ systemctl status mbpfancs.service
● mbpfancs.service - mbpfan Custom Service
Loaded: loaded (/etc/systemd/system/mbpfancs.service; enabled; vendor preset:
Active: activating (start) since Sat 2019-09-28 12:17:54 UTC; 2h 41min ago
Main PID: 13324 (mbpfan)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/mbpfancs.service
└─13324 /usr/sbin/mbpfan -f
Sep 28 12:17:54 macmini systemd[1]: Starting mbpfan Custom Service...
Sep 28 12:17:54 macmini mbpfan[13324]: mbpfan starting up
您可以创建自定义服务,如下所述。
但是,您需要知道
mbpfan
系统上可执行文件的确切路径。为此,请在终端中运行以下命令:你会得到这样的输出:
复制输出并
PATH_TO_MBPFAN
用它替换下面的服务文件。然后,请按照以下说明进行操作。首先,
mbpfan
通过在终端中运行以下命令来创建和编辑自定义 systemd 服务:其次,将以下代码复制并粘贴到编辑器中,替换
PATH_TO_MBPFAN
为的输出which mbpfan
并按Ctrl+保存文件,X然后按Y然后按Enter:第三,通过在终端中运行以下命令来启动服务:
第四,通过在终端中运行以下命令来启用该服务:
最后,重新启动系统。