Skip to content

Useful scripts

VirtuBox edited this page Oct 22, 2018 · 5 revisions

Script to set a command for all miners

#!/bin/bash
baseUrl="http://admin:pass@localhost:3344"
command="UPDATE_CONFIG"

curl "$baseUrl/admin/getClientStatusList" --silent | awk -F"[,:}]" '{for(i=1;i<=NF;i++){if($i~/\042'client_id'\042/){print $(i+1)}}}' | tr -d '"' | sed -n ${num}p | while read -r line ; do
        curl -H "Content-Type: application/json" -X POST -d '{"control_command":{"command":"'$command'"}}' "$baseUrl/admin/setClientCommand?clientId=$line"
done

Script to get a list of all miners

#!/bin/bash
baseUrl="http://admin:pass@localhost:3344"

curl "$baseUrl/admin/getClientStatusList" --silent | awk -F"[,:}]" '{for(i=1;i<=NF;i++){if($i~/\042'client_id'\042/){print $(i+1)}}}' | tr -d '"' | sed -n ${num}p | while read -r line ; do
        echo $line
done

Linux systemd script for xmrigDaemon autostart

Create file /lib/systemd/system/xmrigcc.service (don't forget to change /path/to/your/xmrigDaemon)

[Unit]
Description=xmrigCC Daemon

[Service]
ExecStart=/path/to/your/xmrigDaemon
StandardOutput=null

[Install]
WantedBy=multi-user.target
Alias=xmrigcc.service

Then execute this commands to enable and start the service:

systemctl enable xmrigcc.service
systemctl start xmrigcc.service

Linux systemd script for xmrigCCserver autostart

Requirements : screen - you can install it with apt install screen if it's not available on your server.

Create a file /lib/systemd/system/xmrigCCServer.service :
In the following example, replace YOUR_USER with your linux user and set the proper path to xmrigCCServer.

[Unit]
Description=xmrigCCServer
After=network.target

[Service]
User=YOUR_USER
Type=forking
KillMode=none
ExecStart=/usr/bin/screen -d -m -fa -S YOUR_USER /path/to/your/xmrigCCServer
ExecStop=/usr/bin/killall -w -s 2 /path/to/your/xmrigCCServer
WorkingDirectory=%h

[Install]
WantedBy=default.target

Then just enable it with :

systemctl enable xmrigCCServer.service
systemctl start xmrigCCServer