1

I have this script meant to run when booting (named bootMF):

!/bin/bash
cd /media/pi/2E2D-29D01
sleep 120
python3 telnetRX006RBN.py &
sleep 10
python3 telnetRX006DXK.py &
sleep 70
python3 analyse039.py &
sleep 60
python3 WatchDog002.py &
exit

I inserted this line in .profile:

(sleep 15 && /home/pi/bootMF) &

Now when I reboot with 'shutdown -r now' all python scripts are started twice as you can see here:

pi@raspberrypi:~ $ ps -ef | grep python
pi        1470     1  0 15:41 ?        00:00:02 python3 telnetRX006RBN.py
pi        1472     1  0 15:41 tty1     00:00:01 python3 telnetRX006RBN.py
pi        1474     1  0 15:42 ?        00:00:00 python3 telnetRX006DXK.py
pi        1476     1  0 15:42 tty1     00:00:00 python3 telnetRX006DXK.py
pi        1478     1 14 15:43 ?        00:01:20 python3 analyse039.py
pi        1480     1 14 15:43 tty1     00:01:21 python3 analyse039.py
pi        1496     1  0 15:44 ?        00:00:00 python3 WatchDog002.py
pi        1497     1  0 15:44 tty1     00:00:00 python3 WatchDog002.py
pi        1594  1446  0 15:52 pts/0    00:00:00 grep --color=auto python

Can anyone tell me why they are started twice? When I run bootMF manually using 'bash bootMF' they only start once.

4
  • .profile is a (no offense) dumb place to start one-off services as it is not something which is guaranteed to be loaded only once. See INVOCATION under man bash.
    – goldilocks
    Commented Jun 27, 2017 at 17:22
  • no offense taken :-), complete newbie on linux here. Thanks for your input. Commented Jun 27, 2017 at 17:55
  • removed the command from .profile and added it to rc.local. Seems to work better now. Commented Jun 27, 2017 at 18:13
  • @ON5MF Could you add this as an answer, so that people know the problem has been fixed.
    – user67191
    Commented Jun 28, 2017 at 5:04

1 Answer 1

0

as stated in the comments .profile is not a good place to put a script that needs to start when booting Raspbian.

So now I put it in rc.local and it works a lot better.

1
  • Please accept your own answer with a click on the tick on its left side. Only this will finish the question and it will not pop up again year for year.
    – Ingo
    Commented Jan 28, 2020 at 12:48

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.