[Linux] Using systemd to run a miner

As mining is a task meant to run continuously it is recommended to run orax-cli mine using a process manager/supervisor. We will see here how to use systemd for running your miner.

Download and register the miner

# Download the orax-cli binary
wget -O orax-cli https://oraxpool.s3.ca-central-1.amazonaws.com/orax-cli/orax-cli-linux-amd64
# Or the ARM version
# wget -O orax-cli https://oraxpool.s3.ca-central-1.amazonaws.com/orax-cli/orax-cli-linux-arm64
chmod +x orax-cli
sudo mv orax-cli /usr/local/bin/orax-cli
# Register your miner
orax-cli register

Set up systemd

Create a systemd unit file sudo nano /lib/systemd/system/orax.service with the following content while replacing the root user with your current user at the line User=root.

Description=Orax miner
ExecStart=/usr/local/bin/orax-cli mine

Now load, enable and start Orax miner unit:

sudo systemctl daemon-reload
sudo systemctl enable orax
sudo systemctl start orax
sudo systemctl status orax

Read the logs

To read the logs, use journalctl:

journalctl -u orax.service --output cat
# To follow the logs:
journalctl -u orax.service --output cat -n 80 -f