2

Background: hobby coder running Raspbian on a Model B.

I've deployed a RPi in my brother's garage. It connects to a few temperature / moisture / etc sensors (via Python, over a serial connection) and records readings to a mysql db. Every half hour it averages these readings and POSTs to a little REST API I wrote on my server (after which it deletes the transmitted rows from the SQL DB) - the server then draws some pretty graphs.

I would like to interact with the unit as little as possible moving forward and have a few questions about how best to achieve that. Let's pretend - as unrealistic as this may be - I'd like it to be plodding along doing the exact same stuff in 5 years time.

  1. Reboots - I've noticed the Pi slows down after a few weeks of use, so I've got it restarting automatically every 14 days. Is this normal? Should I expect that 14 day interval to drop over time?

  2. Free space - I have an 8gb SD card. Practically, I'm never going to fill that up. Academically, I'm sure that if I measured free space ~1 week apart there would be a decrease because of various bits of logging that Linux core (and Python and cron and MySQL) get up to in the background. Is there a way I can stop this? Should I? Is Linux clever enough to set a TTL on these logs or delete them if it starts to get low on space?

  3. Hardware - Is it fair to expect a few years of continuous use out of the Pi before the hardware starts failing? The only relevant factors I can think of are a) it's in a little dust-shielding case, but b) it's not very processor-intensive work, so it runs quite cool.

Appreciate any ideas!

1

You should not need to reboot a Linux system, except to install OS updates. Your slowdown over time is probably the result of a program leaking memory and eventually causing page faults, which would be very slow from a SD card filesystem. Try ps -eF --sort -rss, which will show all of the processes on the system, sorted with highest memory use first, just after a reboot, and then after 7 and 14 days to see if you can identify the culprit. Memory use is shown two different ways, in the SZ and RSS columns. Restart the offending program, and your system will run fine.

Most Linux distributions will automatically rotate logs on a regular basis, compressing the older ones, and deleting them after a period of time, so your system should reach some level of logs and then level off. You can tune this by editing /etc/logrotate.conf

A Raspberry Pi on clean power should last several years; my oldest one is just over a year of continuous running (in a weatherproof box outside with ambient temperatures from -10 to +90F).

1

1) I´ve heard that the first time - is it possible you have installed a program with a little memory leak?

3) I am running a RPI model B for about a year now, having quite heavy CPU use - and I did not have any problems with the hardware...
If you write much to the SD card, the maximum number of write cycles could be a problem (but as far as I have understood is this not the case).

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.