I am running raspbian and my pi boots straight to desktop. I am wondering how I could schedule a script to run at boot to desktop and not at power-on.

4 Answers 4


Did exactly the same in my Raspberry PI. Add the command to run your application to ~/.config/lxsession/LXDE/autostart as it follows:

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash

@python /home/pi/python_cool_stuff/yourscript.py

You use two ways here :

  • using rc.local to shell-scripted desktop detection and running your script at the right time
  • using your desktop environment's autorun capabilities. startx script can utilize .xinitrc scripts by auto-including and executing them. In case that you need to exec your script after/inside not just a GUI, but a display manager - read its man page. The default LXDM is well-documented here. Basically you'll just use a .desktop file

I use this for a reboot button.

sudo nano /etc/rc.local

Then, above the last line:

python /home/pi/scripts/reboot.py &

  • /etc/rc.local is executed when the OS is starting, the /home/user/.bashrc is executed when a user login.
    – MatsK
    Commented Oct 4, 2017 at 21:06

I had the same requirement. I found the best way was using cron. Best thing about cron is you do not need to login and you can fully control the process, how many time to run, when to run etc..

See this Link

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.