π οΈ Raspberry Pi β Manage Startup Applications (2025 Boot Automation Guide)
π§² Introduction β Run Apps Automatically on Raspberry Pi Boot
Whether youβre building a kiosk display, launching a sensor monitoring script, or auto-starting a web server, managing startup applications on Raspberry Pi ensures your services or scripts run automatically after bootβwithout manual intervention.
π― In this guide, youβll learn:
- How to auto-run Python scripts, apps, or services on Raspberry Pi
- Use methods like
rc.local,cron,systemd, and.desktopfiles - Best practices to ensure stability, logging, and recovery
- Example use cases: web server, LED controller, GUI apps
βοΈ Method 1: rc.local (Legacy Boot Script β CLI or Lite Mode)
β Step 1: Edit the rc.local file
sudo nano /etc/rc.local
β
Step 2: Add your command before exit 0
Example (Python script):
python3 /home/pi/startup/blink.py &
β
The & lets it run in background.
π§ Works on Raspberry Pi OS Lite, but deprecated in newer OS releases. Use systemd for long-term reliability.
β±οΈ Method 2: Cron @reboot (Simple & Lightweight)
β Step 1: Edit cron jobs
crontab -e
β Step 2: Add this line at the end
@reboot python3 /home/pi/startup/weather.py >> /home/pi/logs/weather.log 2>&1
β
This logs all output into weather.log and runs your Python script every time Pi boots.
π§© Method 3: systemd Services (Best for Services or Daemons)
β Step 1: Create a service file
sudo nano /etc/systemd/system/myscript.service
β Step 2: Add the following:
[Unit]
Description=My Python Script at Boot
After=network.target
[Service]
ExecStart=/usr/bin/python3 /home/pi/startup/monitor.py
WorkingDirectory=/home/pi/startup
StandardOutput=inherit
StandardError=inherit
Restart=always
User=pi
[Install]
WantedBy=multi-user.target
β Step 3: Enable and start
sudo systemctl daemon-reexec
sudo systemctl enable myscript.service
sudo systemctl start myscript.service
β Use this method for background services, network wait, or restart-on-failure apps.
π₯οΈ Method 4: Autostart GUI Apps (for Desktop Mode)
If you want a Python GUI, browser, or kiosk app to launch at login:
β
Step 1: Create a .desktop file
nano ~/.config/autostart/myapp.desktop
β Step 2: Add:
[Desktop Entry]
Type=Application
Name=MyApp
Exec=python3 /home/pi/gui/clock.py
β Works only if Pi boots into GUI (PIXEL/Desktop environment).
π Comparison Table β Startup Method Use Cases
| π Method | π§° Best For | π Boot Mode | π Restart Capable |
|---|---|---|---|
rc.local | CLI-based one-liners/scripts | Headless (Lite) | β No |
cron @reboot | Simple tasks, no monitoring | All | β No |
systemd | Services, servers, GPIO apps | All | β Yes |
.desktop files | GUI apps, browsers, PyQt apps | Desktop Only | β No |
π§ Real-World Use Cases
| π οΈ Project | π‘ Startup Method |
|---|---|
| Sensor data logger | cron or systemd |
| Flask web server | systemd |
| OLED display controller | rc.local or systemd |
| Chromium kiosk mode browser | .desktop + GUI |
| MQTT listener service | systemd |
| LED blinking script | cron or rc.local |
π Summary β Recap & Next Steps
You can make your Raspberry Pi automatically launch scripts, servers, GUI tools, or background services with easeβimproving automation, uptime, and headless functionality.
π Key takeaways:
- Use
systemdfor services with logging and restart support - Use
cronfor lightweight boot tasks - Use
.desktopfor graphical startup on GUI login - Use
rc.localfor quick one-line startup (legacy)
βοΈ Real-world relevance: Ideal for IoT projects, smart home setups, data logging, media servers, and unattended applications.
β FAQs β Raspberry Pi Startup Applications
β My script runs but fails silently at boot. Why?
β
Most likely missing environment paths or permissions. Log output to a file or use systemd for better error handling.
β How can I delay a script after boot?
β
Add sleep in cron or systemd like:
ExecStart=/bin/bash -c 'sleep 10 && python3 /path/to/app.py'
β Can I run multiple apps on boot?
β
Yes. Use multiple @reboot lines, .desktop files, or separate systemd units.
β What happens if my systemd service crashes?
β
Add Restart=always or on-failure to restart the service automatically.
β How to remove a service I added?
sudo systemctl disable myscript.service
sudo rm /etc/systemd/system/myscript.service
Share Now :
