0
votes

i wanted to know what would be the best approach to solving this issue. I would like to run a bunch of commands to run some python scripts and a service when the raspberry pi loads into the desktop. Here are my commands:

cd /var/www/html/
python servocontrol.py


cd /var/www/html/Misc 

python temp1.py
python seven_segment.py

sudo /etc/init.d/livestream.sh start

My initial method which i read on most post was to add it in the rc.local by:

sudo nano /etc/rc.local

And paste the exact commands in it as follows:

#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

sleep 15
cd /var/www/html/
python servocontrol.py
cd /var/www/html/Misc
python temp1.py
python seven_segment.py
sudo /etc/init.d/livestream.sh start
exit 0

Sadly it didn't work. Kindly if any one can point out what i am missing or if there are additional steps that need to be done for this to work. If there are other methods i am also open to them!

Thanks

2

2 Answers

1
votes

you can use crontab on raspberry pi (The crontab (short for "cron table") is a list of commands that are scheduled to run at regular time intervals on your computer system. The crontab command opens the crontab for editing, and lets you add, remove, or modify scheduled tasks.)

AND you can create service for your script. it's very easy just need 5 sec search to find instruction.

0
votes

are you want execute a script in server start? you can use @reboot in cron