Skip to content

Instantly share code, notes, and snippets.

@Ernillew
Created September 23, 2017 02:10
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save Ernillew/38762b95432b05194d06dd7d208624a0 to your computer and use it in GitHub Desktop.
Save Ernillew/38762b95432b05194d06dd7d208624a0 to your computer and use it in GitHub Desktop.
systemd-unit for xmrig
[Unit]
Description=XMRig Daemon
After=network.target
[Service]
Type=forking
GuessMainPID=no
ExecStart=/usr/local/bin/xmrig -c /home/miner/config/config.json -l /home/miner/xmrig.log -B
Restart=always
User=miner
[Install]
WantedBy=multi-user.target
@88plug
Copy link

88plug commented Aug 29, 2021

My version with root access for randomx 1gb pages and custom json based on hostname

[Unit]
Description=XMRig Daemon
After=network.target

[Service]
Type=forking
ExecStartPre=/bin/bash -c "/bin/systemctl set-environment HOSTNAME=$(hostname)"
ExecStart=/home/user/moneroocean/xmrig --config=/home/user/moneroocean/${HOSTNAME}.json
Restart=always
User=root

[Install]
WantedBy=multi-user.target

@erik9u2
Copy link

erik9u2 commented Jan 14, 2022

Would it be wrong to use Type=simple here?

@xmrjoe2
Copy link

xmrjoe2 commented Sep 12, 2023

Would it be wrong to use Type=simple here?

Indeed, I could not get it to work as Type=forking (It would hang indefinitely if I did "systemctl start xmrig.service"). It had to be Type=simple, then it was fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment