I am hacking around with a component on a board that needs networking. To accomplish that I open a terminal at startup and I added a startup.sh script to the bottom of my ~/.bashrc. However, when I restart and then run a process check I notice 2 instances.
pi 841 826 0 07:17 tty1 00:00:00 /bin/bash --rcfile ./bin/startup.sh
pi 998 985 0 07:17 pts/0 00:00:00 /bin/bash --rcfile ./bin/startup.sh
Now if I remove the line from .bashrc and then add after startup and open a terminal I only get 1 instance. I disable the line in the bashrc before opening the other terminal to run ps
so it shouldn't be that either (also seems to be confirmed by PID)
Why is this happening? Can I make it so only 1 is starting?
.bashrc
to do anything other than configure the shell/environment is a bad practice that for whatever reason is virulent among pi users -- likely due lousy blogs spreading it like a virus..profile
or.bashrc
are scripts executed by the system at boot. They aren't -- they are executed on a per user basis whenever a new shell is started, depending on context. If you are using the system interactively (i.e. via a keyboard, etc.), or logging in remotely, this could happen many times, and not only at boot. See INVOCATION inman bash
. You've gotten around part of the issue by using--rcfile
so that that file won't normally be used.