# systemd unit file for the Python Demo Service # copy this file to /lib/systemd/system # sudo systemctl daemon-reload # sudo systemctl enable python_isttok_influx.service # https://www.codementor.io/@ufukafak/how-to-run-a-python-script-in-linux-with-systemd-1nh2x3hi0e [Unit] # Human readable name of the unit Description=Python Influx write Service After=network.target [Service] # Command to execute when the service is started #ExecStart=/usr/bin/pythoni3 /usr/local/lib/python_demo_service/python_demo_service.py ExecStart=/bin/bash -c 'cd /home/bernardo/EPICS/ISTTOK/epics/influxDB && /usr/bin/python3 isttok_to_influx.py' # Disable Python's buffering of STDOUT and STDERR, so that output from the # service shows up immediately in systemd's logs Environment=PYTHONUNBUFFERED=1 # Automatically restart the service if it crashes Restart=on-failure # Our service will notify systemd once it is up and running Type=notify # Use a dedicated user to run our service User=bernardo [Install] # Tell systemd to automatically start this service when the system boots # (assuming the service is enabled) WantedBy=default.target