Having trouble turning mbpfan into a system service
I'm a beginning Ubuntu user following this tutorial to enable fan management with mbpfan on my Mac Mini 4.1 running Ubuntu 18.04.
I had good success initially and then got to the point of trying to turn mbpfan into a system service. The first glitch I hit was that no mbpfan.service file was present on my system after installation, so I just downloaded it from GitHub, uploaded it via SFTP to my download folder, and then copied it as instructed with sudo cp mbpfan.service /etc/systemd/system/
.
But here's the result when I try to execute 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
I'm kind of stuck at this point and would appreciate a nudge. Thank you.
= = = = = = = = =
Edit 1:
~$ systemctl status mbpfancs.service
Produced:
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.`
And so then
~$ 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)
= = = = = = = = =
Edit 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
Solution 1:
You can create a custom service as explained below.
You will, however, need to know the exact path to the mbpfan
executable on your system. To do so, please run the following command in the terminal:
which mbpfan
You will get an output like this:
/usr/sbin/mbpfan
Copy the output and replace PATH_TO_MBPFAN
in the service file below with it. Then, please proceed with the instructions below.
Firstly, create and edit a custom systemd service for mbpfan
by running the following command in the terminal:
sudo nano /etc/systemd/system/mbpfancs.service
Secondly, copy and paste the following code into the editor replacing PATH_TO_MBPFAN
with the output of which mbpfan
and save the file by pressing Ctrl + X then press Y then press Enter :
[Unit]
Description=mbpfan Custom Service
[Service]
Type=oneshot
ExecStart=PATH_TO_MBPFAN -f
[Install]
WantedBy=multi-user.target
Thirdly, start the service by running the following command in the terminal:
sudo systemctl start mbpfancs
Fourthly, enable the service by running the following command in the terminal:
sudo systemctl enable mbpfancs
Finally, reboot your system.