I haven't found any such command among the listed in the output of xmrig -h. I run the miner with "background": true in config.json.

As my xmrig is started in the background by a script that makes sure that my miner runs all the time in the background I need to know a command that gracefully exits the miner, under certain conditions included in the script. If there is such a command I would then add it to my script so that my miner can be stopped automatically. Because of the above reasons managing xmrig via tmux does not solve the problem, at least I can't see a way in which I can script starting and stopping xmrig with tmux.

  • 1
    pkill xmrig ?? (-9 to be nasty about it, if pkill supports -9) There was a small program ttyecho which can pipe/send commands into a tty. Would have to run ttyecho as root/sudo – Dave Jul 21 at 15:35
  • Scripting tmux is easy. Start xmrig in a named window, and kill-window the named window to kill it. – jtgrassie Jul 21 at 22:51

I've created a systemd unit file for xmrig: Command line options

nano /etc/systemd/system/xmrig.service

Description=XMRig Daemon
ExecStart=/home/user/xmrig/xmrig --config=/home/user/xmrig/config.json

Update systemd configuration and enable xmrig for system startup:

systemctl daemon-reload
systemctl enable xmrig.service

start, stop, status as usual:

systemctl start xmrig.service
systemctl status xmrig.service
systemctl stop xmrig.service
  • You should remove --background (because you've used Type=simple), and remove StandardOutput=null, StandardError=null, so you can read the output/log messages with journalctl. Lastly, on most systemd distros, you should create your custom service files under /etc/systemd/... not /usr/lib/systemd/; they will be correctly linked when enabled. – jtgrassie Jul 22 at 14:51
  • Thanks, changed it. – boldsuck Jul 23 at 0:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.