Tuesday, September 24, 2013

Energy saving with Raspberry Pi ssh server

I've noticed that after couple days of running my Raspberry Pi server (Raspberry Pi driven Dropbox alternative) I had a problem with connectivity to ssh. Not sure why, but it doesn't really bother me, as I've noticed it only once up to now. Once restarted ssh worked again.

Anyway as I don't need it to be running 24/7 but rather there are couple hours in night, when there is definitely no need to have it up.

Electronic timer switch

As I had a chance to buy electronic timer switch at "Flohmarkt" (in Riem seems to be one of the biggest ones), as it was a good deal I bought 3, where 2 seem to work (still it was worth it). After some googling I've found quite detailed manual (for I guess the British version).

Final setup

I ended up with following:
  • electronic timer switch has been programmed in the way it turns off at 01:00am and goes back on at some time in the morning (depending on weekday or weekend) and
  • cron job has been setup to switch the Raspberry Pi 5 minutes before hard unplug (in my setup are 5 mins enough):
    # m h dom mon dow command
    55 0 * * * /sbin/shutdown -h now
    
That's it. I neither need to worry about hard shutdown (and mess caused to my data) nor about manual startup my ssh server. It's been working fine for couple weeks already for me.