Hi, I have bunch of WD drives, which seem to ignore hdparm -S command. It is actually a known bug of many WD drives. So I compiled hd-idle package from http://hd-idle.sourceforge.net/ (make & make install went fine) and it installed into /usr/local/sbin/hd-idle
When I invoke it from command line, it runs in the background and I see it running with ps ax and it does control drive power-downs.
me@opensuse:~/Downloads/hd-idle> sudo /usr/local/sbin/hd-idle -l /var/log/hd-idle.log -i 0 -a /dev/sdb -i 300 -a /dev/sdc -i 300 -a /dev/sdd -i 300 -a /dev/sde -i 300 -a /dev/sdf -i 300
[sudo] password for root:
me@opensuse:~/Downloads/hd-idle> ps ax | grep hd-idle
1802 ? S 0:00 /usr/local/sbin/hd-idle -l /var/log/hd-idle.log -i 0 -a /dev/sdb -i 300 -a /dev/sdc -i 300 -a /dev/sdd -i 300 -a /dev/sde -i 300 -a /dev/sdf -i 300
1805 pts/4 S+ 0:00 grep --color=auto hd-idle
me@opensuse:~/Downloads/hd-idle> sudo pkill hd-idle
me@opensuse:~/Downloads/hd-idle> ps ax | grep hd-idle
1810 pts/4 R+ 0:00 grep --color=auto hd-idle
But when I try to run it as service, it exits with code 0, but does not stay running and it does not power down disks. What is the difference between running command from .service file and from command line? Is there some hidden magic in maybe service type? Why it does not stay resident?
me@opensuse:~/Downloads/hd-idle> sudo cat /etc/systemd/system/hd-idle.service
[Unit]
Description=hd-idle spin down for HDDs
[Service]
Type=simple
ExecStart=/usr/local/sbin/hd-idle -l /var/log/hd-idle.log -i 0 -a /dev/sdb -i 300 -a /dev/sdc -i 300 -a /dev/sdd -i 300 -a /dev/sde -i 300 -a /dev/sdf -i 300
[Install]
WantedBy=multi-user.target
######
# so I try to run the service with exactly the same parameters:
me@opensuse:~/Downloads/hd-idle> sudo systemctl start hd-idle.service
me@opensuse:~/Downloads/hd-idle> sudo service hd-idle status
* hd-idle.service - hd-idle spin down for HDDs
Loaded: loaded (/etc/systemd/system/hd-idle.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Tue 2019-12-03 13:03:38 CET; 38s ago
Process: 1817 ExecStart=/usr/local/sbin/hd-idle -l /var/log/hd-idle.log -i 0 -a /dev/sdb -i 300 -a /dev/sdc -i 300 -a /dev/sdd -i 300 -a /dev/sde -i 300 -a /dev/sdf -i 300 (code=exited, status=0/SUCCESS)
Main PID: 1817 (code=exited, status=0/SUCCESS)
Dec 03 13:03:38 server systemd[1]: Started hd-idle spin down for HDDs.
#######
# it returns exit code 0 like from command line, but it does not stay running:
me@opensuse:~/Downloads/hd-idle> ps ax | grep hd-idle
1850 pts/4 R+ 0:00 grep --color=auto hd-idle
Thank you for help.