Reputation: 495
I am new to Raspberry Pi and I wanted to run a program automatically after the Pi bootsup. I script works fine when I tried to run ./myscript.sh
. As it is need to run everytime the Pi powered-up, I have mentioned the script path in /etc/rc.local
as /home/pi/myscript.sh
above exit 0
.
Once I reboot the Pi, I could see the log messages from my script and so on, but when I tried to see the process Id I found two process for the application I start using the script.
root 607 1 11:30 ? 00:00:00 /bin/sh -e /etc/rc.local start
root 615 607 11:30 ? 00:00:00 /bin/bash /home/pi/myscript.sh
root 684 615 11:30 ? 00:00:00 sudo ./rte -bf runappl.xml
root 689 684 11:30 ? 00:00:00 ./rte -bf runappl.xml
and myscript.sh will look like
#!/bin/bash
echo " Configuring eth0 multicast ... "
sudo ifconfig eth0 multicast
sudo route add -net 224.0.0.0 netmask 240.0.0.0 dev eth0
export rte_bin_dir="../home/pi/rte/bin/"
if [ -d "$rte_bin_dir" ]; then
cd "./$rte_bin_dir"
sudo ./rte -bf runappl.xml
else
echo "unable to locate ${rte_bin_dir}"
exit 1
fi
Is this the correct result expected or am I assuming something wrong?
Is there a way to run the script automatically after I see the desktop(main screen)
Upvotes: 1
Views: 570
Reputation: 1172
This is normal, as you are sudoing your command. One process (684) is used for the switch user part (sudo here), the other one (689) for the program itself.
So it's ok, your program is not running twice.
Upvotes: 3