If you have a raspberry on some location and it must run a python script "forever" (a year, maybe two, without me being on location), how often should I reboot it? I know people are keeping them alive for a year+, but I wrote a simple script that can reboot it at given time + raspberry will automatically run the python script on boot.
I've got a couple of Pis running my Ham Radio repeater and irrigation system - realistically, I'm rebooting them maybe once every 6 months for security updates or some other "maintenance" reason; but I've not seen issues where a reboot was REQUIRED to "keep things running"
In terms of hardware, the only reason you should ever need to reboot an ARMHF-y board is firmware changes, necessary changes to ROM, or possibly new devices that must be present at boot.
For instance, adding a driver or close-to-metal kernel module and a device implementing that driver will probably need a reboot, just to tell the CPU and kernel memory mapper about the change. You can update the Linux kernel without rebooting.
In terms of software, all the major computing environments available for the Pi are *nix-like1, in that they're True Unix™ or in that they use Linux or a Linux derivative and are thus (U)nix-y.
Unix and its derivatives are designed from the bootloader up to userland to be fully scalable, portable and reliable; they were designed for servers that never or almost never undergo a hard reset (aka being fully shut down and cold-booted from scratch), and, to a lesser extent, embedded devices exactly like Raspberry Pis. Consequently, these goals indeed apply on the Pi.
This means in practice, you basically never need to reboot your Pi (or your *nix desktop PC, for that matter).
1Ignoring, for a moment, the Microsoft Windows 10: Internet Of Things Edition for the Pi, which I wish to be a practical joke but isn't.
With embedded "run forever" systems, periodic reboots are unnecessary. It is common to use a hardware watchdog timer to detect a system hang and reboot. I believe the watchdog timer is more valuable than a periodic reboot (the reboot probably won't work if the system is hung).
I agree with the things written before. In a theoretical situation with excellently written software with perfect error handling, no memory leaks..., a reboot won't be neccesary.
I have more than 50 PI's (all PI 3) on site, and some get rebooted weekly and others never... Almost all of the PI's are used in kiosk mode, either playing videos, displaying a website, running scripts,... User expercience is important to me and I can't afford to have a PI failing. I have a watchdog installed on all of them.
On my site, I'm using the following approach (this is only using my own experience, no scientific background :-))
PI's that run servers (Apache, SIP,...) and are only connected with an ethernet cable: I never reboot them, some of them have an uptime of almost 2 years (indeed, I didn't upgrade those)!
on the contrary, PI's that run videoloops (using OMXPlayer): I reboot those devices weekly. I've tried to not reboot them at all, but I discovered that occasionaly the video hangs without watchdog even noticing. So one would see a still image on screen. I'd say that during a one month period there was -for each of the devices- roughly a 50% chance that the video would freeze once, To minize those risks, I decided to reboot once per week and the results are acceptable: so far, after a year of weekly reboots, I only had 2 freezes (image freeze, no PI freeze). Of course I would love to eliminate those as well, but this is another topic. For those, I don't care about the impact of a reboot on the SD-card, since, if this would ever occur, it is simply putting a new SD-card and update the template with the right video.
PI's that are in client mode and display web-based user content (using Chromium, KWeb,...) with user interaction (primarily touchscreens and/or buttons): I reboot those every month and so far haven't had any issues. Maybe it was not needed to reboot them... but given those devices run scripts (Java, Node.js) and get input from other devices I thought that at some point a reboot might be needed, so I decided to go for a monthly reboot.
I realize this is not giving a direct answer to your question, but I just wanted to share some personal experience so you can -together with the other answers- judge what the best approach for your project would be.
protected by goldilocks♦ Jan 17 '18 at 16:19
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?