Skip to content

Linux

Since linux has a bunch of distros, this tutorial is not going to cover detailed Python setup process. So, make sure that you have Python installed.

shell
cd path/to/your/client/folder
pip install -r requirements.txt
python3 client.py

Auto start at boot

To run this script automatically when boot, you could use client/device-status.service

  1. download & modify this file on line 8:
ini
[Unit]
Description=Device Status Client
After=network.target

[Service]
Type=simple
WorkingDirectory=/home/orangepi/homeserver/device-status
ExecStart=/usr/bin/python3 /path/to/device-status/client.py
Restart=on-failure
RestartSec=5s

[Install]
WantedBy=multi-user.target
  1. create & paste systemd file:
sudo nano /etc/systemd/system/device-status.service
  1. enable service:
shell
sudo systemctl daemon-reload
sudo systemctl enable device-status.service
sudo systemctl start device-status.service

Running in the Background

If you want this script to run in the background, use screen

Debian / Ubuntu / Kali / Raspberry Pi OS:

shell
sudo apt update
sudo apt install screen

Arch Linux / Manjaro:

shell
sudo pacman -S screen

...

After installing, verify with:

shell
screen --version

Create a new session:

shell
screen -S device-status

Run the client script in this newly created session. Use Ctrl+A & D to detach from the session.