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

More
3 years 2 months ago - 3 years 2 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: 3 years 2 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
3 years 2 months ago #4422 by mw0uzo
That's great information, thank you for posting!

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

Time to create page: 0.141 seconds
Powered by Kunena Forum
Solar powered Raspberry Pi 4 server stats: CPU 30% Memory 14% Swap 18% CPU temp=66.2'C Uptime 63 Days