The Python script is unable to work in rc.local, as soon as it nevet gets executed. My idea is to run the script when the Raspberry Pi gets boot.
I have tested it with this sentence. The log.txt file only appears when I execute the program manually.
f = open("log.txt", "w")
f.write("log is working")
f.close()
Before that, I have tried to insert a time.sleep(30), to use usr/bin/python3, to change the head of the script to #!/usr/bin/env python3
, change the user is executing the program to -u pi
and a lot of things I can't even remember.
The final sentence is had before exit(0) is
sudo /usr/bin/python3 /home/pi/script.py &
rc.local is working as soon as it runs an echo that I have create in the file.