There are many ways to run a python program as a background service on your raspberry pi at startup. We will use the systemd method.
.service
file for your service as below:sudo nano /lib/systemd/system/helloworld.service
[Unit] Description=Hello World Service After=multi-user.target [Service] Type=idle ExecStart=/usr/bin/python /home/pi/helloworld.py User=pi [Install] WantedBy=multi-user.target
Ctrl+X
).sudo chmod 644 /lib/systemd/system/helloworld.service
sudo systemctl daemon-reload
sudo systemctl start helloworld.service
sudo systemctl stop helloworld.service
sudo systemctl enable helloworld.service