This article was co-authored by wikiHow staff writer, Nicole Levine, MFA. Nicole Levine is a Technology Writer and Editor for wikiHow. She has more than 20 years of experience creating technical documentation and leading support teams at major web hosting and software companies. Nicole also holds an MFA in Creative Writing from Portland State University and teaches composition, fiction-writing, and zine-making at various institutions.
This article has been viewed 150,387 times.
Learn more...
Whether it be used as a media center, web server, gaming console, or simply a computer, there are countless reasons why you might need a particular program or script to automatically start when you boot your Raspberry Pi. This wikiHow teaches you how to force a script to start at boot time by either adding it as a service (before the desktop loads), or by adding it to your autostart file (after the desktop loads).
[Unit]
Description=My Service
After=network-online.target
[Service]
ExecStart=/usr/bin/python3 -u main.py
WorkingDirectory=/home/pi/myscript
StandardOutput=inherit
StandardError=inherit
Restart=always
User=pi
[Install]
WantedBy=multi-user.target
@lxterminal -e "/home/pi/myscript.sh"