0

I tried running two scripts on boot using below link.

https://www.instructables.com/id/Raspberry-Pi-Launch-Python-script-on-startup/

One of the file just requires to open camera while other requires sending data to firebase real time database. Above tutorial successfully started file having requirement of opening camera but it didn't work for firebase file because Pi is connected to wifi after boot.

Is it possible to to run both scripts after my Pi 3 connects to wifi after boot? or another workaround?

1 Answers1

1

There's six places where you can easily get things running at boot time.

  1. Add a line to /etc/rc.local with sudo nano /etc/rc.local. Add your program before the exit 0 line. Put an & on the end of the line if it starts a long running process.
  2. Add an @reboot line to your personal crontab with crontab -e
  3. Add an @reboot line to root's crontab with sudo crontab -e
  4. Add a cron line in /etc/crontab (not recommended).
  5. Add a line to your autostart file in /home/pi/.config/lxsession/LXDE-pi/autostart which looks like @/usr/bin/python3 /home/pi/thing_to_start.py
  6. Create a systemd service file in /etc/systemd/system/myscript.service which has this basic structure

    [Unit]
    Description=Thing to start at boot time
    
    [Service]
    Type=simple
    ExecStart=/usr/bin/python3 /home/pi/thing_to_start.py
    
    [Install]
    WantedBy=multi-user.target
    

There are other ways to get things running but those are the six most popular. If the program you're starting uses the GUI use the autostart method.

Dougie
  • 5,381
  • 11
  • 22
  • 30