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

More
5 years 7 months ago - 5 years 7 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: 5 years 7 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
5 years 6 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.303 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 45% Memory 17% Swap 18% CPU temp=55.0'C Uptime 9 Days