Creating Service
How to create service
Creating basic service
Create service file my.service
[Unit]Description=My serviceAfter=network.target[Service]ExecStart=/usr/bin/python -u main.pyWorkingDirectory=/home/pi/myserviceStandardOutput=inheritStandardError=inheritRestart=alwaysUser=pi[Install]WantedBy=multi-user.target
Copy service file to the /etc:
sudo cp my.service /etc/systemd/system/my.service
Update configuration:
sudo systemctl daemon-reload
Start service:
sudo systemctl start my
Stop service:
sudo systemctl stop my
Start on a boot
Enable service for starting on a boot
sudo systemctl enable my
Check status:
sudo systemctl status my