I can't figure out how to get python to reboot my raspberry pi once a day. I have no code to show for what I have tried. I'm sure someone here can tell me how.
Asked
Active
Viewed 713 times
0
-
3Does this answer your question? [restart local computer from python](https://stackoverflow.com/questions/4629131/restart-local-computer-from-python) – bantix Apr 07 '20 at 17:11
-
Sorry "bantix" but this is a raspberry pi not a windows device that I'm using. Thanks for tying though – UNKNOWN Apr 07 '20 at 17:37
-
1What exactly is the issue? Have you done any research? A simple google search leads to plenty of information. – AMC Apr 07 '20 at 19:43
1 Answers
1
import os
os.system("reboot")
Look into cron jobs on the operating system of your choice to execute this regularly
Execute a daily reboot on a raspberry pi
Go to shell, give the python script execution rights with sudo chmod +rwx /path/to/script.py
sudo su
nano /etc/crontab
Enter in the crontab file the following
@daily root /path/to/script.py

Björn
- 1,610
- 2
- 17
- 37
-
Great answer. Now can you tell me how to reboot it once a day with python script? – UNKNOWN Apr 07 '20 at 17:38
-
1@UNKNOWN as I wrote this depends on your operating system.Which OS do you use? What you are looking for is a cron job – Björn Apr 07 '20 at 17:41
-