How to run pyradmon.py in Systemd on Ubuntu 18.04.2-LTS to get GQ GMC-320 online

More
4 years 10 months ago - 4 years 10 months ago #4417 by Marc
pyradmon.py is a little python script I need running on an Ubuntu 18.04.2-LTS server to get data from my GMC 320 Geiger Muller counter from GQ electronics to its data showing webpage here on radmon.
It has to always run and restarted if it fails.
On Ubuntu 18 and many other systems a system called Systemd is in use to facilitate this.
To install the script:
sudo chmod +x pyradmon.py 
sudo apt-get install python-serial
sudo adduser yourusername dialout
sudo reboot
To get the script running in Systemd do the following:

Create a file called "radmon.service" in /etc/systemd/system .
[Unit]
Description=Radmon service
After=network.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=30
User=marc
ExecStart=/usr/bin/python -u /home/marc/GMC/pyradmon.py
StandardOutput=console
StandardError=inherit

[Install]
WantedBy=multi-user.target
Then do:
sudo systemctl enable radmon.service
sudo systemctl start radmon.service
And if needed do:
sudo systemctl status radmon.service
sudo systemctl restart radmon.service
sudo systemctl stop radmon.service

That's it.

Marc PC1MH
Attachments:
Last edit: 4 years 10 months ago by Marc. Reason: Error repaired
The following user(s) said Thank You: mw0uzo

Please Log in or Create an account to join the conversation.

More
4 years 10 months ago #4422 by mw0uzo
That's great information, thank you for posting!

Please Log in or Create an account to join the conversation.

Moderators: Gamma-Man
Time to create page: 0.114 seconds
Powered by Kunena Forum
Everything's free. Please support us by considering a donation. Log in first!
Solar powered Raspberry Pi 4 server stats: CPU 32% Memory 13% Swap 11% CPU temp=52.1'C Uptime 19 Days