POSTINIT Script - Log Question

Hi Everyone!

Noob question here :slight_smile: I do have a script to control some FANs via IPMI and it is working fine, here is the code:

#!/bin/sh

echo “IPMI - FAN Setting Start”

Set FAN mode to “full”

ipmitool raw 0x30 0x45 0x01 0x01
sleep 1.25

Set FAN speed in “system” zone to 45%

ipmitool raw 0x30 0x70 0x66 0x01 0x00 0x2D
sleep 1.25

Set FAN speed in “peripheral” zone to 70%

ipmitool raw 0x30 0x70 0x66 0x01 0x01 0x46
sleep 2

Print-out the current FAN speed

echo “IPMI - Current FAN Speed”
ipmitool sdr | grep -e FAN1 -e FANA

The only thing that I dont see is the print of those messages in DMESG…

Tried to look anywhere at /VAR/LOG and nothing is there :frowning:
Used this command to try to find it
grep -rnw ‘/var/’ -e ‘FAN’ and nothing related to the ECHO messages.

What I am doing wrong? :slight_smile:

Thanks in Advance!

im not a bash expert but i’m pretty sure that when you use

echo “IPMI - Current FAN Speed”
ipmitool sdr | grep -e FAN1 -e FANA

you are effectively not logging anything, but only serving those data in the standard output.
Probably just adding something like >> "/mnt/*****" 2>&1 (obv replacing the path location with something real) on each row do the job.

echo “IPMI - Current FAN Speed”  >> "/mnt/*****" 2>&1
ipmitool sdr | grep -e FAN1 -e FANA  >> "/mnt/*****" 2>&1

IMHO better if you define a var on top of the script like LogDir="/mnt/*****" and then use it instead of the hard path on each row

echo “IPMI - Current FAN Speed”  >> "$LogDir" 2>&1
ipmitool sdr | grep -e FAN1 -e FANA  >> "$LogDir" 2>&1

in case of need, change first line instead of n lines (and if script grows, can be a pain)

Another way is to use logger.

It has been a while since I used logger to write system log entries. But, if I remember correctly, setting the parameters can allow writing to both /var/log/messages and console.

You should be able to test this in a script, before making it a post init script.