(2022-02-07, 10:37 PM)Newbie1979 Wrote: Hi,
I am looking for a way to initiate a python script upon start-up (it is a 1sec restart/ 3 sec safe shutdown button script). On my other RPI sec installation it a simple edit of rc.local, but that does not seem to do the trick in Openplotter (v2).
Thanks for your help!
Have you tried cron?
In a terminal edit the cron file with the command
Select your preferred editor (you only do this once) and at the bottom of the file add the following (here I am assuming I have a script called test.py and it is located in /home/pi/, adjust this of course for your particular circumstances.
Code:
@reboot python3 /home/pi/test.py
If you reboot then the script should have executed.
If your script requires root privilege then precede the "python3" with "sudo"
To test it start perhaps with a trivial script which just creates a file called somefile.txt, here's an sample test.py to do this:
Code:
import os
os.system('touch somefile.txt')
I always like to test this manually. Run in a terminal window
Code:
python3 /home/pi/test.py
There should now be a file called somefile.txt in the directory you ran the command from.
DELETE IT then reboot and a new one should be created.
Having proved the process use the real script you want to execute.