I have created a python script that lights up some leds on a bit of breadboard then it's supposed to shut down the pi, the script works fine if I run it in python and the pi shuts down as intended.
I created a crontab using sudo crontab -e
@reboot /path/to/myFile.py
And chmod a+x myFile.py
On boot the script runs just fine and the leds light as intended but it just will not shutdown at the end of the script, spent the last two days trying to figure this out. The shutdown part looks like this
os.system("lxterminal -e sudo shutdown -h now")
but it seems cron is ignoring this, been reading around and can't seem to find the answer anywhere but from what I understand now cron won't open a terminal
I tried making a file in /home/pi/.config/autostart/
that would run the file on startup, if I double click the file it runs but on reboot nothing. Tried chmod
and still nothing.
Tried making a separate file that shuts down after 5 minutes and tried all different things with that but to no avail, driving me crackers.
How can I get the pi to shutdown at the end of my python script using cron?