Run Logger.py on Startup - mjdeventer/AQ-JDMB GitHub Wiki
We want to run our python data acquisition and logger on powerup of the Pi without the need to attach a keyboard or screen:
in the example below, we assume that your python logger is named "logger.py"
credits to Matt from raspberrypi-spy
1. create a service file using the command line editor:
sudo nano /lib/systemd/system/logger.service
2. configure the service file:
[Unit]
Description=Logger Service
After=multi-user.target
[Service]
Type=idle
ExecStart=/usr/bin/python3 /home/pi/logger.py
[Install]
WantedBy=multi-user.target
3. exit the command line editor by:
[CTRL-X], [Y] then [ENTER]
4. Set permissions:
sudo chmod 644 /lib/systemd/system/logger.service
5. Configure systemd during startup:
sudo systemctl daemon-reload
sudo systemctl enable logger.service
6. Reboot the Pi and your custom service should run :
sudo reboot
7. check the status of your service using :
sudo systemctl status logger.service
if needed: stop the service
sudo logger.service ssh stop