Recently I had the problem that my MagicMirror did not work properly after two days at the latest. For some reason, the screen was black and it was not clear at first glance how to fix this problem.
As a temporary solution, only a restart of the RaspberryPI helped.
However, as I did not manage to find the cause of the problem for the following days, I needed a “provisional solution” for the actual time.
Because starting the RaspberryPi every day is annoying – especially if you can automate this process.
As a permanent solution for the time being it helped to automatically restart the RaspberryPi every night.
How to do it and what you have to pay attention to is described in the following article.
Hints for our lovely english readers: Basically, many of the articles on Nerdiy.de are translations from the original german articles. Therefore, it may happen here and there that some illustrations are not available in english and that some translations are weird/strange/full of mistakes or generally totaly wrong. So if you find some obvious (or also not obvious) mistakes don't hesitate to leave us a hint about that in the comment section.
Also please don't get confused, that instead of a "dot" often a "comma" is used as decimal separator. 🙂
I know the following hints are always a bit annoying and seem unnecessary. But unfortunately, many people who knew it "better" from carelessness lost their eyes, fingers or other things or hurt themselves. In comparison, a loss of data is almost not worth mentioning, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Even the coolest project is worth no injury or other annoyance. https://www.nerdiy.de/sicherheitshinweise/
Before you start with this article, you should have prepared the RaspberryPi so far that it can be reached via the network and controlled by SSH. This is explained in the following articles:
RaspberryPi – Setting up for Nerdiys!
RaspberryPi – The first configuration
RaspberryPi – Controlling the RaspberryPi via SSH
In the following list you will find all the parts you need to implement this article.
Log in via SSH on the RaspberryPi
To get started, you first need to log in to RasPi with SSH on Putty. How to do it is described in the article RaspberryPi - Controlling the RaspberryPi via SSH.
Set up automatic restart
In order for the RaspberryPi to start automatically at the desired time you have to edit the crontab. The “crontab” is a table (hence the “tab”) in which all cronjobs – that is to say, regularly executed activities – are entered. To view and edit them, just enter the following command:
sudo crontab -e
There you enter the following line:
0 2 * * * /sbin/shutdown -r now
You set the time through the information before the actual restart command.
In this case (0 2 * * *), the following command is executed at the zeroth minute and the second hour of each day.
So the following scheme applies:
* * * * *Command
| | | | |
| | | | +—– Weekday (0 – 7) (Sonntag ist 0 und 7)
| | | +——- Month (1 – 12)
| | +——— Day (1 – 31)
| +———– Hour (0 – 23)
+————- Minute (0 – 59)
The command to reboot at five o’clock in the morning would be: 0 5 * * */sbin/shutdown -r now
The command to reboot at 1:30 am: 30 1 * * * /sbin/shutdown -r now
I hope everything worked as described. If not or you have any other questions or suggestions, please let me know in the comments. Also, ideas for new projects are always welcome. 🙂
P.S. Many of these projects - especially the hardware projects - cost a lot of time and money. Of course I do this because I enjoy it, but if you appreciate it that I share these information with you, I would be happy about a small donation to the coffee box. 🙂