Power USB at certain CPU temperature

I have an unusual server set-up. Basically, I have a combination of salvaged parts from 3 Powerbook G4s running a non-graphical distribution of lubuntu. Problem is, I’m better with hardware than the software side of things.

I’m powering a USB fan (as all other connectors are gone) that I want to turn on when the CPU reaches a certain temperature. Eventually I’ll install a proper temperature sensor, but for now that will have to do.

I’m sure there’s a simple script I could write for this which could run in the background monitoring the temperature and enabling power to the USB port. Any ideas? Suggestions?

Asked By: user1652011

||

i think you could turn on/off your fan by running the following command:

# turn off
echo suspend > /sys/bus/usb/devices/usbX/power/level

# turn on
echo on > /sys/bus/usb/devices/usbX/power/level

replace usbX with usb1, usb2 or whatever

then you would have to check the temperatur periodically, for example by running a script every minute using cron job. You can take a look at this german article to see how to implement it. Don’t worry if you do not speak german. The bash script from the example is pretty easy to understand without the surrounding text.

Answered By: Yevgeniy M.
Categories: Answers Tags: , , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.