Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

330
Vistas
Autostart does not work after user reboot

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

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

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:

 $ sudo nano /etc/init.d/superscript
 Save and exit: Ctrl+X, Y, Enter

Make the script executable:

 $ sudo chmod 755 /etc/init.d/superscript

Register script to be run at startup:

 $ sudo update-rc.d superscript defaults

2. Start At Login

Make sure you are in the pi folder:

 $ cd ~

Create a file and write a script to run in the file:

 $ sudo nano superscript

Paste contents of sh script here

 Save and exit: Ctrl+X, Y, Enter

Open up .bashrc for configuration:

 $ sudo nano .bashrc

Scroll down to the bottom and add the line: ./superscript

 Save and exit: Ctrl+X, Y, Enter

3. Start with Desktop Environment

(Your method which sounds like its not working for your needs)

over 4 years ago · Santiago Trujillo Denunciar

0

I suggest to edit your crontab.

$crontab -e

or

$sudo crontab -e

The last line should be

@reboot /home/pi/mog/run.sh

If it doesn't work you can try creating an autostart folder

mkdir ~/.config/autostart
cd ~/.config/autostart

create a .desktop file like this:

[Desktop Entry]
Type=Application
Exec=yourscript.sh
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=Startup Script

Move your yourscript.sh in /usr/local/bin folder and it should run after reboot

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda