I want to autostart a sh script after reboot.
I add below line to /etc/xdg/lxsession/LXDE-pi/autostart
.
@/home/pi/mog/run.sh
Everything works fine if i plug the raspberrypi-2 to power line or switch on it after halt. However when i run shell command
sudo shutdown -r now
the autostart method does not work after reboot?
I want to run a C++ application after reboot and my run.sh script is below.
#!/bin/bash
sleep 5
/home/pi/mog/mog -platform xcb
I suggest to edit your crontab.
or
The last line should be
If it doesn't work you can try creating an autostart folder
create a .desktop file like this:
Move your yourscript.sh in /usr/local/bin folder and it should run after reboot
I guess it depends on what type of shell script you are trying to run.
Looks like there are several ways to do it:
1. Start with Console
Create a file for your startup script and write your script in the file:
Make the script executable:
Register script to be run at startup:
2. Start At Login
Make sure you are in the pi folder:
Create a file and write a script to run in the file:
Paste contents of sh script here
Open up .bashrc for configuration:
Scroll down to the bottom and add the line: ./superscript
3. Start with Desktop Environment
(Your method which sounds like its not working for your needs)