I need to set an environment variable and run an app when the Raspberry Pi boots up. To that end, I added the following to
export MY_ENV_VAR=foo cd /home/pi/MyApp ./MyApp
When I reboot the Pi, the app is definitely running and the environment variable is set. However, when I log in, the application is executed again - e.g. .bashrc is run on both login and boot.
How can I ensure that my script is only executed once at boot time and not at login?
P.S. I've tried copying the script /etc/rc.local, but then it doesn't run at all.