my raspberryPi keeps rebooting and I have no idea how to solve this problem other than recovery the image. I haven't backuped for a while so I prefer not to recover it from an old one.
I added two lines of code in rc.local file hoping to run two python scripts at boot. These two python scripts run in indefinite loops. One of them has a condition. if met, then it will run
After I added the lines and started the system to test it out. Both programs were booted successfully and after the condition was met, the system started to reboot. But it just got stuck in the reboot process and I switched the SD card to another Pi and it is doing the same thing.
Is there a way to enter recovery mode maybe? Or any other ways to stop it from rebooting?
Any suggestions will be appreciated!
Here is python script that reboots the PI once the condition is met
beginTime = time.time() try: while True: paths = glob("/home/pi/odas/recordings/cSST*.raw") # paths might be empty at the very beginning if not paths: print("cSST files have been not created yet") flagTime = beginTime else: latestFilePath = max(paths, key=os.path.getatime) latestFileTime = os.path.getatime(latestFilePath) flagTime = latestFileTime currentTime = time.time() delta = currentTime - flagTime print(delta) if delta > 120: os.system("reboot now") time.sleep(2) except KeyboardInterrupt: print("User interrupt")
So this script is monitoring files in a folder. If 2 minutes have passed and there are no new files being generated then reboot the system