Reboot If RAM Low

Hey,

I finished setting up my x86 SBC with dietpi and everything works like a charm.

Because I use it for DNS resolving with Unbound and blocked other devices from using port 53, it’s important to me that it works when I am not at home.

Restarting daily would be possible but that clears the Unbound cache, which I would prefer not to.

So my idea is to configure a cron job that reboots the system at 4 am if RAM > 90% to avoid memory leak issues.

My questions is how such a cron job would look like.
Or if there is a better solution.

When the RAM usage is constantly increasing you already have a memory leak.
You could also just restart the process, or limit the memory usage of the process instead of restarting the whole system.

But these are all just meaurements to control the symptoms, but not the cause.
Do you know which process has the memory leak?

Why do you need to restart your system? My RPI is running unbound and Pihole with a low memory footprint. It’s not growing in any kind.

Did you already experience any memory shortage already? Probably better to check which app it is. For sure not unbound or Pihole

No, I don’t have any problems.
I just thought that would be a good idea because if it happens I guess SSH also wouldn’t work and I need to power cycle my device.

So you say I shouldn’t mind this?
I only use software from dietpie’s optimized list.

Ok forget what I said.
A tasmota smart plug will just do the job.
And because I use a quality SSD i can power cycle without risking data corruption.

Anyway, thanks for your answers!
It was me, thinking to complicated…

It would be best to observe the memory usage over time. And don’t just assume any memory leak. There shouldn’t be one. My PiHole has been running for weeks and only reboots for software updates. Regular reboots should not be necessary.

1 Like

Ok, that sounds reasonable.
I’ll check RAM usage periodically and because I don’t need port forwarding on my dietpi I shouldn’t need to update it for months either.

Best practice is to keep a system up-to-date. Software updates offer many advantages. They involve revisions. They include fixing discovered security vulnerabilities and correcting or eliminating computer bugs. Updates can add new features to your devices and remove outdated ones. This will ensure your operating system is always running on the latest version.

2 Likes