I want to run this working .sh file when I boot into the LXDE (preferably when it is completely loaded):

mkdir /tmp/stream &

raspistill --nopreview -w 1024 -h 768 -q 70 -o /tmp/stream/pic.jpg -tl 100 -sh 100 -vs -t 9999999 -th 0:0:0 &

LD_LIBRARY_PATH=/usr/local/lib mjpg_streamer -i "input_file.so -f /tmp/stream -n pic.jpg" -o "output_http.so -w /usr/local/www" &

forever /home/pi/tank/index.js

Last attempt, I tried to use the instructions in this thread, resulting in a disaster.. had to reinstall completely.

Will my script run if I just add the following to my .bashrc file?


I really want to make sure before I try this..

Thanks in advance

  • This question had to be posted in the unix.stackexchange.com forum, since it's not raspberry-specific Commented Mar 19, 2019 at 15:45

2 Answers 2


Ok, fixed it with the instructions below. I add this answer because this is quite specific (run when desktop is loaded).

open up the file using nano:

sudo nano /etc/xdg/lxsession/LXDE/autostart

add the following line to the bottom of the file (just as last line)

@sh /home/pi/myproject/myscript.sh

save and reboot!

You could put the call to your script in /etc/rc.local Make sure you run it in the background ( so add & at the end of your call ). The calls in rc.local will be run when the pi boots at the end of the boot process. Please note, your script will not have access to the screen or the keyboard when run from rc.local. This may not be a problem, although I'm not sure what the final line 'forever index.js' does.

  • The request was to wait until after the LXDE environment is loaded before running the script. rc.local is a system script that runs at the end of each multi-user run-level & is the last thing to be run as the system boots. It however, is in no way dependent upon or will it wait for the user to log in to the system through the login manager, and cannot know when the LXDE session has loaded completely.
    – colpanic73
    Commented Jul 2, 2022 at 12:10

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.