1

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:

  1. Once booted automatically open Terminal
  2. cd to/my/directory
  3. run_my_script.py
  4. After 10 minutes, close terminal (or reboot) and repeat

I have limited knowledge of shell and desktop scripts.

1
  • 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. Commented Jan 10, 2018 at 10:41

1 Answer 1

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

https://docs.python.org/3/library/subprocess.html

3
  • 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? Commented 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.html Commented 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 +10 Commented Jan 10, 2018 at 11:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.