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?


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.

  • This is perfect, thanks heaps for your help. You're a life saver. Your example worked off the bat. Thank you :) – user1652011 Nov 26 '12 at 9:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.