Recently I had the problem that my MagicMirror did not run properly after two days at the latest. For some reason the screen stayed black and it was not obvious at first glance how to fix this problem.
As a provisional solution only a restart of the RaspberryPI's helped for the time being.
Since I didn't get around to finding the cause of the problem in the following days, I needed a “temporary, permanent” solution.
Because restarting the RaspberryPi every day is annoying - especially when you can automate this process.
As a permanent solution for now, it helped to let the RaspberryPi reboot automatically every night.
How to do this and what you need to consider is described in the following article.
Safety instructions
I know the following notes are always kind of annoying and seem unnecessary. Unfortunately, many people who knew "better" have lost eyes, fingers or other things due to carelessness or injured themselves. Data loss is almost negligible in comparison, but even these can be really annoying. Therefore, please take five minutes to read the safety instructions. Because even the coolest project is not worth injury or other trouble.
https://www.nerdiy.de/sicherheitshinweise/
Affiliate links/advertising links
The links to online shops listed here are so-called affiliate links. If you click on such an affiliate link and make a purchase via this link, Nerdiy.de will receive a commission from the relevant online shop or provider. The price does not change for you. If you make your purchases via these links, you support Nerdiy.de in being able to offer other useful projects in the future. 🙂
Requirements
Helpful articles:
Before you start with the article you should prepare the RaspberryPi so that it is accessible via the network and controllable via SSH.
The following three articles describe what needs to be done to prepare the RaspberryPi:
RaspberryPi – setup for nerdiys!
RaspberryPi – The first configuration!
RaspberryPi – Control the RaspberryPi via SSH
Required tool:
-no-
Required material:
In the following list you will find all the parts you need to implement this article.
Log in to the RaspberryPi via SSH
To start, you must first log in to the Rasp Pi with Putty via SSH. How to do this is in the article RaspberryPi - Control the RaspberryPi via SSH described.
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 cron jobs – i.e. activities that need to be carried out regularly – are entered. To view and edit these, simply enter the following command:
sudo crontab -e
There you enter the following line:
0 2 * * /sbin/shutdown -r now
You set the time via the information before the actual restart command.
In this case (0 2 * * *) the following command (in this case the restart but it works also with other commands) is executed at the zero minute and at the second hour of each day.
So the following scheme applies:
* * * * Command to be executed
| | | | |
| | | +-- Weekday (0 - 7) (Sunday is 0 and 7)
| | +--- month (1 - 12)
| +--- day (1 - 31)
| +---- hour (0 - 23)
+----- minute (0 - 59)
Examples:
So the command for a reboot at five in the morning would be: 0 5 * * /sbin/shutdown -r now
The command for a reboot at 1:30 am: 30 1 * * * /sbin/shutdown -r now
Have fun with the project
I hope everything worked as described for you. If not or you have questions or suggestions please let me know in the comments. I will then add this to the article if necessary.
Ideas for new projects are always welcome. 🙂
PS 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 think it's cool that I share the information with you, I would be happy about a small donation to the coffee fund. 🙂