Skip to main content
added 972 characters in body
Source Link
Yihan Hu
  • 37
  • 1
  • 5

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.

Background

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 os.system('reboot now')

Problem

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.

Question

Is there a way to enter recovery mode maybe? Or any other ways to stop it from rebooting?

Any suggestions will be appreciated!

EDITED

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

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.

Background

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 os.system('reboot now')

Problem

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.

Question

Is there a way to enter recovery mode maybe? Or any other ways to stop it from rebooting?

Any suggestions will be appreciated!

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.

Background

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 os.system('reboot now')

Problem

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.

Question

Is there a way to enter recovery mode maybe? Or any other ways to stop it from rebooting?

Any suggestions will be appreciated!

EDITED

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

Source Link
Yihan Hu
  • 37
  • 1
  • 5

RaspberryPi keeps rebooting after i changed rc.local file

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.

Background

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 os.system('reboot now')

Problem

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.

Question

Is there a way to enter recovery mode maybe? Or any other ways to stop it from rebooting?

Any suggestions will be appreciated!