How to reboot DietPi once a day?

A noob question if I may: how could I get DietPi to reboot itself once a day, say at 4:00am when I should be sound asleep?

Background: I use DietPi on a Hyper-V VM to run Pi-Hole for my home network. It works well and uses very little resources…sort of.

I find that Pi-Hole has some kind of memory leak or something. After some days, Hyper-V manager says the instance of DietPi is now using 16GB of ram(!) I normally have Hyper-V set to give this VM only 512MB and it works fine in this small amount of memory.

But maybe there is some kind of bug in Pi-Hole that causes memory usage to skyrocket. I’m not sophisticated enough to know even where to troubleshoot this. So I’ve been mindlessly restarting Pi-Hole from its dashboard.

Rather than go through the above restart process, I’m thinking that I can be lazy and have DietPi reboot itself once a day. Crude, I know. But it will suffice. I just now need to know to get DietPi to autoreboot without knowing much about Linux… “Cron” something???

usually if you assign a fix amount of memory to a VM container, the application inside the container should not be able to use more memory than assigned. I guess inside the VM, it will be still 512MB ram. PiHole is one of the most popular apps on DietPi. If there would be a real memory leak, we would have way more reports. But you are basically first/only one reporting such. Did you had a look into the VM and checking memory consumption using htop command? How does it looks like? And where do you see the huge amount of memory used? Inside the VM or on the Windows host system using task manager?

Thanks for the reply. The memory leak (if it is that at all; I’m actually not sure; it’s my stab at what the problem is) is apparent in the “Assigned Memory” column of Hyper-V manager. It had climbed to 16GB, which is unusually high as the initial amount of memory I gave it was 512MB. I did enable dynamic memory and so maybe something run amok.

Because I rebooted the VM only yesterday, I will report back in a few days with results from htop if the VM does it again. It will take a few days before the situation will again arise; it always does.

It’s not just the assigned memory goes up dramatically. The operation of Pi-Hole slows down. Firstly, any clients that use Pi-Hole have their Internet access become slow or pages don’t load. And then when I look into the reasons why, I come across Pi-Hole and find that its dashboard is sluggish (normally very fast). And then I notice that the Assigned Memory has gone up dramatically like I had mentioned. I’m only guessing but maybe the VM is paging out frantically to its “disk”.

By the way, I’m just a beginner user of DietPi and a beginner at Linux period. But I am impressed at what it can do with so few resources. I’m thinking of spinning up a Wordpress VM for fun and learning using DietPi because of its low resource requirements. Thanks for making this OS available to us.

enabling dynamic memory might not be a good idea and usually not needed. Especially not for PiHole application.

To have a look to check memory consumption, you could open htop and change view to List by using F5 function key. This way you should be able to sort the list by column RES. Now you should see the process consuming memory most. PiHole process usually did not require more than 20MB ram.

That’s how it looks on my system

  0[|                             2.0%] Mem[|||||                   113M/3.80G]
  1[|                             0.7%] Swp[                             0K/0K]
  2[                              0.0%] Tasks: 19; 1 running
  3[                              0.0%] Load average: 0.16 0.11 0.09
Avg[|                             0.7%] Uptime: 3 days, 23:06:19
  PID USER        RES▽ NI CPU%   TIME+  Command
  581 root      22484   0  0.0  0:23.93 php-fpm: master process (/etc/php/7.4/fp
  556 pihole    18508 -10  0.0 14:10.43 /usr/bin/pihole-FTL
  462 unbound   18080   0  0.0  9:40.02 /usr/sbin/unbound -d -p
15680 www-data  14188   0  0.0  0:00.09 php-fpm: pool www
15846 www-data  13592   0  0.0  0:00.26 php-fpm: pool www

Thanks. Here is a screen cap of the current situation. If you see anything out of the ordinary, let me know.

https://imgur.com/a/vCMrLBf

Things are performing ok now and Hyper-V hasn’t assigned more than 512MB of RAM yet. I’ll give it a few more days and check on it.

I may indeed disable dynamic memory as you suggested but I’ll wait until the problem resurfaces (and get another screen cap).

that looks pretty much ok. Keep an eye on processes growing for memory consumption.