4

I am running a service called "thinkfan" for controlling the fan speed of my thinkpad laptop. The service reads the data temperature from a temporary file in a folder. This file is created every now and then, but if thinkfan happens to be started before the file is created it will crash. To prevent this on boot, I added the line

ExecStartPre=/bin/sleep 20

to the systemd file

[Unit]
Description=simple and lightweight fan control program
After=syslog.target

[Service]
Type=forking
EnvironmentFile=-/etc/default/thinkfan
ExecStartPre=/bin/sleep 20
ExecStart=/usr/sbin/thinkfan $DAEMON_ARGS
PIDFile=/var/run/thinkfan.pid
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target

The problem is that the same occurs on wake up from standby, so I am looking for a way to restart the service after a few seconds every time my laptop wakes up after resuming.

1 Answer 1

1

I figured out how to do it: just change the systemd file to

[Unit]
Description=simple and lightweight fan control program
After=syslog.target
After=suspend.target

[Service]
Type=forking
EnvironmentFile=-/etc/default/thinkfan
ExecStartPre=/bin/sleep 20
ExecStart=/usr/sbin/thinkfan $DAEMON_ARGS
PIDFile=/var/run/thinkfan.pid
ExecReload=/bin/kill -HUP $MAINPID
Restart=always

[Install]
WantedBy=multi-user.target

where I simply added After=suspend.target and Restart=always.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.