I got a script from link: https://forum.openmediavault.org/index.php?thread/6902-fan-control/. which I plan to use to control fan speed according to harddisk temperature and CPU temperature.
After I finished check actual sensor and controller by pwmconfig, modify it with actual sensor and controller.
change the script privilege to executable script. run it with root privilege.
run it in terminal then it report error.
fan_controllers.sh: line 19: used: command not found
the detail of the script like below, something I marked with annotation, purpose to trial run the script.
#!/bin/bash
HDDS="/dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde"
HDT=hddtemp
LOG=
DOWN=
ALERT_LEVEL=50
args="--numeric"
VALUE_SIDE=0
VALUE_BACK=0
#while true
#do
#sleep 1
CPU=0
VALUE_SIDE=0
VALUE_BACK=0
I=0
for disk in $HDDS
do
HDTEMP=$(hdparm -C $disk)# This is line 19. used to inspect the harddisk status,whether it is in status of standby or some others
if [[ $HDTEMP != *standby* ]]; then
VALUE_SIDE=$(($VALUE_SIDE + 255))
VALUE_BACK=150
I=$(($I + 1))
fi
done
CPU1=$(cat /sys/class/hwmon/hwmon0/temp1_input) #hwmon0 is CPU temperaturer sensor
CPU2=$(cat /sys/class/hwmon/hwmon0/temp2_input)
#CPU3=$(cat /sys/class/hwmon/hwmon1/device/temp4_input)
#CPU4=$(cat /sys/class/hwmon/hwmon1/device/temp5_input)
#CPU=$(($CPU1 + $CPU2 + $CPU3 + $CPU4))
#CPU=$(($CPU / 4000))
CPU=$(($CPU1 + $CPU2))
CPU=$(($CPU / 2000))
if [ $CPU -ge 40 2>&- ]; then
VALUE_BACK=105
fi
if [ $CPU -ge 45 2>&- ]; then
VALUE_BACK=150
fi
if [ $HDTEMP -ge 55 2>&- ]; then
VALUE_BACK=255
fi
if [ $I -ge 1 2>&- ]; then
VALUE_SIDE=$(($VALUE_SIDE / $I))
fi
echo $VALUE_SIDE
echo $VALUE_BACK
#echo 1 > /sys/class/hwmon/hwmon3/pwm1_enable #pwm1 is chase fan it will be decided by actual boards
#echo 1 > /sys/class/hwmon/hwmon3/pwm2_enable #CPU fan
#echo $VALUE_SIDE > /sys/class/hwmon/hwmon3/pwm1
#echo $VALUE_BACK > /sys/class/hwmon/hwmon3/pwm2
#done
the OS is Openmedialvault6, based on debian.
I suspect the problem caused by the command "hdparm", but when I try it separately in terminal, it works, no issue report.
hdparm -C /dev/sda
/dev/sda:
drive state is: active/idle
I run it with root privilege.
I don't know what happened, would someone could give me some advice about it?
Thanks!
Hope could find the reason why reports
fan_controllers.sh: line 19: used: command not found
and solve it.