Skip to content

Instantly share code, notes, and snippets.

@TheNicholasNick
Last active May 6, 2018 18:10
Show Gist options
  • Save TheNicholasNick/5a9df1aa5d8d5ca08acfb71dd92558d6 to your computer and use it in GitHub Desktop.
Save TheNicholasNick/5a9df1aa5d8d5ca08acfb71dd92558d6 to your computer and use it in GitHub Desktop.
limit xmr-stak via cgroups linux, ubuntu 16.04

setup cgroups v1 to limit process on linux have top running and see the miner cpu usage

/etc/cgrules.conf

user:process_name cpu group
example:

trtlminer:xmr-stak cpu app/xmrstak

/etc/cgconfig.conf

group app/xmrstak {
  cpu {
    cpu.cfs_quota_us =30000;
    cpu.cfs_period_us=100000;
  }
}

30% 1 cpu, multiply number if multiple CPUs and processes 2x processes to use 30% of 2x CPUs, 30% on each = 60,000

run this

sudo cgconfigparser -l /etc/cgconfig.conf
sudo cgrulesengd

/bin/refresh

for i in $(pgrep -w xmr-stak); do echo $i > /sys/fs/cgroup/cpu,cpuacct/app/xmrstak/tasks; done

^ needs to be run as root

add cronjob

* * * * * /bin/refresh_xmrstak_cgroup

so now cpu usage should have dropped

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