I have been struggling with this all day. My set up is a RPi 3 B, running Raspbian.
I need to simply fulfil the following:
- Once booted automatically open Terminal
- cd to/my/directory
- run_my_script.py
- After 10 minutes, close terminal (or reboot) and repeat
I have limited knowledge of shell and desktop scripts.
Chetan Bhargava
1,2523 gold badges15 silver badges29 bronze badges
-
You want to reboot RPi every 10 minutes after running the script? why? You probably don't need to launch terminal to run a python script.hcheung– hcheung2018年01月10日 10:41:27 +00:00Commented Jan 10, 2018 at 10:41
1 Answer 1
wrote a bash script with folling content:
#!/bin/bash
python3 /path_to_your_script/python_script.py
sudo shutdown -r +10
# or with sleep
sleep(600)
sudo reboot now
r: reboot
+10: 10 minutes
go to:
sudo nano /etc/rc.local
and fill in the path to bash script, before the exit 0 statement:
bash /path_to_bash/bash_script.sh &
of course you could do it with python so you would not need a separate bash script
answered Jan 9, 2018 at 16:07
-
Thanks for the advice, I will attempt to implement this now. One query I have is that the script seems to not have a command to open the terminal window, is this not possible in a bash script?Infernez– Infernez2018年01月10日 08:09:12 +00:00Commented Jan 10, 2018 at 8:09
-
to open a terminal, use command "lxterminal -e "command_to_execute" manpages.ubuntu.com/manpages/precise/en/man1/lxterminal.1.htmlbierschi– bierschi2018年01月10日 09:57:38 +00:00Commented Jan 10, 2018 at 9:57
-
Here is my script. #!/bin/bash lxterminal -e "cd /home/pi/iot-hub-python-raspberrypi-client-app/ && python wbuoy4.py" sudo shutdown -r +10Infernez– Infernez2018年01月10日 11:09:55 +00:00Commented Jan 10, 2018 at 11:09