IPMI script in Cron Jobs

pwojda

Cadet
Joined
Apr 21, 2021
Messages
8
Hi Community,

I use IPMITOOL to lower fan noise in TrueNas host (Dell R320). The script dynamically adjust fan speed depending on current temperature and runs every 15 minutes. I've added it to Cron Jobs in TrueNas and it works. However, for some reason, when I move host address, user and password to variables it doesn't work. Any idea why?

Works:
ipmitool -I lanplus -H 192.168.1.10 -U root -P 1A!bcd357 raw 0x30 0x30 0x02 0xff 0x1e

Doesn't work:
IPMIHOST=192.168.1.10
IPMIUSER=root
IPMIPW=1A!bcd357
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x02 0xff 0x1e

Regards,
Przemek
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Hi Community,

I use IPMITOOL to lower fan noise in TrueNas host (Dell R320). The script dynamically adjust fan speed depending on current temperature and runs every 15 minutes. I've added it to Cron Jobs in TrueNas and it works. However, for some reason, when I move host address, user and password to variables it doesn't work. Any idea why?

Works:
ipmitool -I lanplus -H 192.168.1.10 -U root -P 1A!bcd357 raw 0x30 0x30 0x02 0xff 0x1e

Doesn't work:
IPMIHOST=192.168.1.10
IPMIUSER=root
IPMIPW=1A!bcd357
ipmitool -I lanplus -H $IPMIHOST -U $IPMIUSER -P $IPMIPW raw 0x30 0x30 0x02 0xff 0x1e

Regards,
Przemek
Try adding a 'shebang' at the top of your script to specify the shell environment, and quote your variables. Like this:
Code:
#!/bin/sh

IPMIHOST=192.168.1.10
IPMIUSER=root
IPMIPW=1A!bcd357
ipmitool -I lanplus -H ${IPMIHOST} -U ${IPMIUSER} -P ${IPMIPW} raw 0x30 0x30 0x02 0xff 0x1e 
Try out the shellcheck.net website to debug shell scripts. It's very handy; you just paste in your script code and it checks for syntax and other errors:

 

pwojda

Cadet
Joined
Apr 21, 2021
Messages
8
Didn't help. Shellcheck.net shows script is ok. but run in TrueNAS doesn't work. I've tried to see the log via shell using command: /var/log/cron but I get reply "permission denied" (I'm logged in as root).
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
Didn't help. Shellcheck.net shows script is ok. but run in TrueNAS doesn't work. I've tried to see the log via shell using command: /var/log/cron but I get reply "permission denied" (I'm logged in as root).
Please post your script, in code tags, so it will be easier to read. How did you edit the script? With vi? Or a different text editor? If you used a Windows text editor, make sure it saves the file with 'Unix' line endings, not the Windows-style CR/LF pairs.

If you can, post a screenshot of your cron job configuration, too.

Odd that you you can't access the cron log as 'root'. How are you trying to view it? With a text editor? You should be able to run tail cron in the /var/log/ directory and see the last entries in the file.
 
Top