{ "version": "https://jsonfeed.org/version/1.1", "user_comment": "This feed allows you to read the posts from this site in any feed reader that supports the JSON Feed format. To add this feed to your reader, copy the following URL -- https://matoken.org/blog/tag/cpulimit/feed/json/ -- and add it your reader.", "home_page_url": "https://matoken.org/blog/tag/cpulimit/", "feed_url": "https://matoken.org/blog/tag/cpulimit/feed/json/", "language": "ja", "title": "cpulimit – matoken's blog", "description": "Is there no plan B?", "icon": "https://matoken.org/blog/wp-content/uploads/2025/03/cropped-1865f695c4eecc844385acef2f078255036adccd42c254580ea3844543ab56d9.jpeg", "items": [ { "id": "http://matoken.org/blog/?p=2881", "url": "https://matoken.org/blog/2020/12/07/do-your-best-to-control-the-temperature-of-raspberry-pi-with-softwar/", "title": "Raspberry Pi \u306e\u6e29\u5ea6\u7ba1\u7406\u3092\u30bd\u30d5\u30c8\u30a6\u30a7\u30a2\u3067\u9811\u5f35\u308b", "content_html": "
\u3053\u306e\u8a18\u4e8b\u306f\u65e5\u672cAndroid\u306e\u4f1a\u79cb\u8449\u539f\u652f\u90e8\u30ed\u30dc\u30c3\u30c8\u90e8 Advent Calendar 2020 \u306e12/07\u5206\u306e\u8a18\u4e8b\u3067\u3059\uff0e
\n\u5185\u5bb9\u306f \u65e5\u672cAndroid\u306e\u4f1a\u79cb\u8449\u539f\u652f\u90e8\u30ed\u30dc\u30c3\u30c8\u90e8 \u7b2c96\u56de\u52c9\u5f37\u4f1a \u3067\u767a\u8868\u3057\u305f\u5185\u5bb9\u3092\u52a0\u7b46\u4fee\u6b63\u3057\u305f\u3082\u306e\u3067\u3059\uff0e
\nRaspberry Pi \u3068\u3044\u3046\u82f1\u56fd\u767a\u306e\u6559\u80b2\u5411\u3051\u3068\u3057\u30662012\u5e74\u306b\u767a\u58f2\u3055\u308c\u305f\u5b89\u4fa1\u306a\u30b7\u30f3\u30b0\u30eb\u30dc\u30fc\u30c9\u30b3\u30f3\u30d4\u30e5\u30fc\u30bf\u304c\u3042\u308a\u307e\u3059\uff0e\u6559\u80b2\u5411\u3051\u3068\u3057\u3066\u767a\u58f2\u3055\u308c\u307e\u3057\u305f\u304c\u8da3\u5473\u306b\u3082\u3088\u304f\u4f7f\u308f\u308c\u3066\u3044\u307e\u3059\uff0eOS\u306f\u6a19\u6e96\u3067\u306fLinux(Debian\u30d9\u30fc\u30b9\u306eRaspberry Pi OS)\u304c\u63a1\u7528\u3055\u308c\u3066\u3044\u307e\u3059\uff0e
\n\u79c1\u306f\u3082\u3063\u3071\u3089\u7701\u96fb\u529b\u306eLinux\u30de\u30b7\u30f3\u3068\u3057\u3066\u4f7f\u3046\u3053\u3068\u304c\u591a\u3044\u3067\u3059\uff0e
\n\u4eca\u590f\u7a7a\u8abf\u306e\u306a\u3044\u90e8\u5c4b\u306e\u81ea\u5b85\u30b5\u30fc\u30d0\u306e\u6a2a\u3067Raspberry Pi 3 model B + Raspberry Pi OS arm64(\u03b2)\u3067\u8a08\u7b97\u3092\u3055\u305b\u3066\u3044\u305f\u306e\u3067\u3059\u304c\uff0c\u3057\u3070\u3089\u304f\u52d5\u304b\u3057\u3066\u3044\u308b\u3068\u56fa\u307e\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\uff0e
\n\u518d\u8d77\u52d5\u3059\u308c\u3070\u3057\u3070\u3089\u304f\u52d5\u304d\u307e\u3059\u304c\u3057\u3070\u3089\u304f\u3059\u308b\u3068\u3084\u306f\u308a\u56fa\u307e\u308a\u307e\u3059\uff0e\u3053\u308c\u3092\u3069\u3046\u306b\u304b\u51fa\u6765\u306a\u3044\u304b\u3068\u8abf\u3079\u3066\u307f\u307e\u3057\u305f\uff0e
\n\u307e\u305a\u306f\u30ed\u30b0\u3092\u9332\u3063\u3066\u307f\u307e\u3059\uff0e
\n* * * * * printf \"`date +\\%s`,`cat /sys/class/thermal/thermal_zone0/temp`,`echo \"obase=2; ibase=16; \\`vcgencmd get_throttled | cut -f2 -dx\\`\" | bc`,`vcgencmd measure_clock arm|cut -f2 -d=`\\n\" >> ~/.temp.log\n
\u5185\u5bb9\u306f\u3053\u3093\u306a\u611f\u3058\u3067\u3059\uff0e(\u5916\u6c17\u6e29\u5ea6\u3082\u9332\u308c\u3070\u3088\u304b\u3063\u305f)
\ndate +%s/sys/class/thermal/thermal_zone0/tempvcgencmd get_throttledvcgencmd measure_clock arm\u30ed\u30b0\u304c\u30d5\u30a1\u30a4\u30eb\u306b\u66f8\u304b\u308c\u308b\u9593\u306b\u30d5\u30ea\u30fc\u30ba\u3057\u3066\u30c7\u30fc\u30bf\u304c\u5931\u308f\u308c\u308b\u306e\u3092\u9632\u3050\u305f\u3081\u306b /etc/fstab \u306e\u30de\u30a6\u30f3\u30c8\u30aa\u30d7\u30b7\u30e7\u30f3\u306b sync \u30aa\u30d7\u30b7\u30e7\u30f3\u3082\u4ed8\u3051\u3066\u304a\u304d\u307e\u3059\uff0e(\u518d\u8d77\u52d5\u304bremount\u3067\u53cd\u6620)
\u30ed\u30b0\u3092\u53d6\u5f97\u3057\u3066\u3044\u308b\u72b6\u614b\u3067\u8ca0\u8377\u3092\u639b\u3051\u307e\u3059\uff0e\u4eca\u56de\u306f /dev/urandom \u3092cat\u3059\u308b\u3053\u3068\u3067\u8a08\u7b97\u3055\u305b\u307e\u3057\u305f\uff0e\u4eca\u56de\u306eRaspberry Pi 3 model B\u306f4core\u3042\u308b\u306e\u30674\u3064\u52d5\u304b\u3057\u3066\u3044\u307e\u3059\uff0e
$ cat /dev/urandom > /dev/null &\n$ cat /dev/urandom > /dev/null &\n$ cat /dev/urandom > /dev/null &\n$ cat /dev/urandom > /dev/null &\n
\u3057\u3070\u3089\u304f\u52d5\u304b\u3057\u3066Raspberry Pi\u304c\u56fa\u307e\u3063\u305f\u5f8c\u306b\u30ed\u30b0\u3092\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3059\uff0e
\nSoC\u306e\u6e29\u5ea6\u304c85\u5ea6\u3092\u4f55\u5ea6\u304b\u8a18\u9332\u3057\u305f\u5f8c\u306b\u56fa\u307e\u3063\u3066\u3044\u308b\u3088\u3046\u3067\u3059\uff0e
\n85\u5ea6\u3068\u3044\u3046\u306e\u306fRaspberry Pi OS\u3067\u306e\u6a19\u6e96\u306eSoC\u5236\u9650\u6e29\u5ea6\u306e\u3088\u3046\u3067\u3059\uff0e\u3053\u306e\u6e29\u5ea6\u306e5\u5ea6\u524d(\u6a19\u6e96\u3067\u306f80\u5ea6)\u304b\u3089\u30b5\u30fc\u30de\u30eb\u30b9\u30ed\u30c3\u30c8\u30ea\u30f3\u30b0\u304c\u59cb\u307e\u308b\u3088\u3046\u3067\u3059\uff0e
\u30b5\u30fc\u30de\u30eb\u30b9\u30ed\u30c3\u30c8\u30ea\u30f3\u30b0\u3067\u30af\u30ed\u30c3\u30af\u304c\u4e0b\u304c\u3063\u3066\u6e29\u5ea6\u304c\u4e0b\u304c\u308c\u3070\u554f\u984c\u7121\u3055\u305d\u3046\u3060\u3051\u306980\u5ea6\u304b\u3089\u30af\u30ed\u30c3\u30af\u304c\u4e0b\u304c\u3063\u3066\u308285\u5ea6\u3092\u8d85\u3048\u3066\u56fa\u307e\u3063\u3066\u3057\u307e\u3063\u3066\u3044\u308b\u3088\u3046\u3067\u3059\uff0e
\n\u30d9\u30fc\u30bf\u7248\u306eRaspberry Pi OS amd64\u3092\u4f7f\u3063\u3066\u3044\u308b\u305b\u3044\u304b\u3082\u3057\u308c\u306a\u3044\u3068\u601d\u3044\uff0c\u6a19\u6e96\u306eRaspberry Pi OS armhf(32bit)\u7248\u306b\u5909\u66f4\u3057\u3066\u540c\u69d8\u306b\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\u304c\u540c\u69d8\u306e\u52d5\u304d\u306e\u3088\u3046\u3067\u3059\uff0e
\u6b63\u653b\u6cd5\u3068\u3057\u3066\u306f\u30d2\u30fc\u30c8\u30b7\u30f3\u30af\uff0c\u30d5\u30a1\u30f3\u306e\u5897\u8a2d\u3084\u7a7a\u8abf\u3092\u5165\u308c\u308b\u3068\u3088\u3055\u305d\u3046\u3067\u3059\u304c\uff0c\u91d1\u6b20\u306a\u306e\u3067\u3068\u308a\u3042\u3048\u305a\u30bd\u30d5\u30c8\u3060\u3051\u3067\u3069\u3046\u306b\u304b\u51fa\u6765\u306a\u3044\u304b\u3068\u8a66\u3057\u307e\u3057\u305f\uff0e
\n\u307e\u305aSoC\u306e\u5236\u9650\u6e29\u5ea6\u3067\u3059\u304c\uff0c\u516c\u5f0f\u30d5\u30a9\u30fc\u30e9\u30e0\u306770\u5ea6\u4ee5\u4e0b\u306b\u3057\u305f\u307b\u3046\u304c\u3044\u3044\u3068\u3044\u3046\u66f8\u304d\u8fbc\u307f\u3092\u898b\u304b\u3051\u307e\u3057\u305f\uff0e\u9006\u306b100\u5ea6\u3067\u3082\u5927\u4e08\u592b\u3068\u3044\u3046\u4eba\u3082\u5c45\u308b\u306e\u3067\u3059\u304c\u5b89\u5168\u5074\u306e70\u5ea6\u306b\u3057\u3066\u307f\u307e\u3059\uff0e
\n\u3053\u306e\u8a2d\u5b9a\u306f /boot/config.txt \u3067\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u8a2d\u5b9a\u3067\u304d\u307e\u3059\uff0e\u4ee5\u4e0b\u306f70\u5ea6\u306b\u8a2d\u5b9a\u305f\u3068\u304d\u306e\u4f8b\u3067\u3059\uff0e\u3053\u306e\u72b6\u614b\u3067\u518d\u8d77\u52d5\u3059\u308b\u3068\u53cd\u6620\u3055\u308c\u307e\u3059\uff0e
temp_limit=70\n
\u518d\u8d77\u52d5\u5f8c\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u8a2d\u5b9a\u304c\u53cd\u6620\u3055\u308c\u3066\u3044\u308b\u304b\u78ba\u8a8d\u304c\u51fa\u6765\u307e\u3059\uff0e
\n$ vcgencmd get_config int | grep ^temp_limit=\ntemp_limit=70\n
\u3053\u306e\u72b6\u614b\u3067\u8ca0\u8377\u3092\u639b\u3051\u308b\u306870\u5ea6\u3092\u8d8a\u3048\u308b\u304f\u3089\u3044\u3067\u56fa\u307e\u308a\u307e\u3057\u305f\uff0e\u3084\u306f\u308a\u5236\u9650\u6e29\u5ea6\u3092\u8d8a\u3048\u308b\u3068\u56fa\u307e\u3063\u3066\u3044\u821e\u3046\u3088\u3046\u3067\u3059\uff0e
\nRaspberry Pi 3 model B \u306eSoC\u306f\u6700\u5927\u5468\u6ce2\u65701.2GHz\u3067\u3059\uff0e\u3053\u308c\u3092\u4e0b\u3052\u3066\u307f\u307e\u3059\uff0e
\n/boot/config.txt \u306e arm_freq= \u3067\u8a2d\u5b9a\u3067\u304d\u307e\u3059\uff0e\u4ee5\u4e0b\u306f800MHz\u306b\u8a2d\u5b9a\u3057\u305f\u3068\u304d\u306e\u4f8b\u3067\u3059\uff0e\u518d\u8d77\u52d5\u3067\u53cd\u6620\u3055\u308c\u307e\u3059\uff0e
arm_freq=800\n
\u518d\u8d77\u52d5\u5f8c\u306b\u8a2d\u5b9a\u304c\u53cd\u6620\u3055\u308c\u3066\u3044\u308b\u304b\u78ba\u8a8d\u3057\u307e\u3059\uff0e
\n$ vcgencmd get_config int | grep ^arm_freq=\narm_freq=800\n
\u3053\u306e\u72b6\u614b\u3067\u8ca0\u8377\u3092\u639b\u3051\u308b\u3068\u3084\u306f\u308a\u56fa\u307e\u308a\u307e\u3059\uff0e\u307e\u3042\u30b5\u30fc\u30de\u30eb\u30b9\u30ed\u30c3\u30c8\u30ea\u30f3\u30b0\u304c\u52b9\u3044\u3066\u3082\u56fa\u307e\u308b\u306e\u3067\u4ed5\u65b9\u304c\u306a\u3044\u611f\u3058\u3067\u3059\uff0e
\n\u6b21\u306bSoC\u6700\u5c0f\u5468\u6ce2\u6570\u3092\u4e0b\u3052\u3066\u307f\u307e\u3059\uff0e\u65e2\u5b9a\u5024\u306f600MHz\u3067\uff0c\u30b5\u30fc\u30de\u30eb\u30b9\u30ed\u30c3\u30c8\u30ea\u30f3\u30b0\u3067\u3082\u3053\u3053\u307e\u3067\u4e0b\u304c\u3063\u3066\u3044\u308b\u306e\u3067\u3053\u308c\u3092\u66f4\u306b\u4e0b\u3052\u308b\u3068\u6e29\u5ea6\u304c\u4e0b\u304c\u308a\u305d\u3046\u306a\u6c17\u304c\u3057\u307e\u3059\uff0e
\n/boot/config.txt \u306e arm_freq_min= \u3067\u8a2d\u5b9a\u3067\u304d\u307e\u3059\uff0e\u4ee5\u4e0b\u306f400MHz\u306b\u8a2d\u5b9a\u3057\u305f\u3068\u304d\u306e\u4f8b\u3067\u3059\uff0e\u518d\u8d77\u52d5\u3067\u53cd\u6620\u3055\u308c\u307e\u3059\uff0e
arm_freq_min=400\n
\u3057\u304b\u3057\u518d\u8d77\u52d5\u5f8c\u306b\u78ba\u8a8d\u3057\u3066\u307f\u308b\u3068600MHz\u3088\u308a\u4e0b\u306b\u306f\u8a2d\u5b9a\u3067\u304d\u306a\u3044\u307f\u305f\u3044\u3067600MHz\u306b\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\uff0e
\n$ vcgencmd get_config int | grep ^arm_freq_min=\narm_freq_min=600\n
\u3053\u306e\u72b6\u614b\u3067\u8ca0\u8377\u3092\u639b\u3051\u308b\u3068\u3084\u306f\u308a600Mhz\u307e\u3067\u3057\u304b\u4e0b\u304c\u3089\u305a\u56fa\u307e\u308a\u307e\u3059\uff0e
\n\u6b8b\u5ff5\u306a\u304c\u3089Raspberry Pi \u306e\u30b9\u30ed\u30c3\u30c8\u30ea\u30f3\u30b0\u3067\u306f\u7121\u7406\u305d\u3046\u3067\u3059\uff0e
\nLinux\u306e\u30d6\u30fc\u30c8\u30d1\u30e9\u30e1\u30fc\u30bf\u3067 maxcpus \u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u30b3\u30a2\u3092\u5236\u9650\u3067\u304d\u307e\u3059\uff0eRaspberry Pi \u306e\u5834\u5408\u306f /boot/cmdline.txt \u3067\u8a2d\u5b9a\u3067\u304d\u307e\u3059\uff0e
\u8a2d\u5b9a\u5f8c\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067\u78ba\u8a8d\u3067\u304d\u307e\u3059\uff0e
\n$ grep -o -E 'maxcpus=.{0,9} ' /proc/cmdline\nmaxcpus=1\n$ grep ^processor /proc/cpuinfo | wc -l\n1\n\u3053\u308c\u3067CPU core1\u6d25\u3067\u52d5\u4f5c\u3057\u3066\u3044\u307e\u3059\uff0e\u3057\u304b\u3057\u6700\u5927\u5468\u6ce2\u6570\u3092600MHz\u304b\u30641core\u3067\u3082\u540c\u69d8\u306b\u30d5\u30ea\u30fc\u30ba\u3057\u3066\u3057\u307e\u3044\u307e\u3057\u305f\uff0e
\nIntelCPU\u306eNotePC\u306a\u3069\u3067\u306fcoufreq\u3092\u4f7f\u3063\u3066\u3053\u306e\u3042\u305f\u308a\u306e\u5236\u5fa1\u3092\u3059\u308b\u306e\u3067\u3059\u304c\uff0c\u3053\u308c\u3067\u3082600mHz\u3088\u308a\u4e0b\u306b\u306f\u4e0b\u3052\u3089\u308c\u306a\u3044\u3088\u3046\u3067\u99c4\u76ee\u3067\u3057\u305f\uff0e
\nLimitCPU\u306f\u6307\u5b9a\u30d7\u30ed\u30bb\u30b9\u3092\u76e3\u8996\u3057\uff0cCPU\u5229\u7528\u7387\u3084%\u3067\u5236\u9650\u3059\u308b\u30d7\u30ed\u30b0\u30e9\u30e0\u3067\u3059\uff0eLinux, MacOS, *BSD\u306a\u3069\u306eUNIX-Likesystem\u3067\u5229\u7528\u3067\u304d\u307e\u3059\uff0e
\nRaspberry Pi OS\u3067\u306fcpulimit\u30d1\u30c3\u30b1\u30fc\u30b8\u3068\u3057\u3066\u30d1\u30c3\u30b1\u30fc\u30b8\u30f3\u30b0\u3055\u308c\u3066\u304a\u308a\uff0c\u30b3\u30de\u30f3\u30c9\u3082coulimit\u3067\u3059\uff0e
$ sudo apt install cpulimit\n
cpulimit\u30b3\u30de\u30f3\u30c9\u306b\u5236\u9650\u3057\u305f\u3044\u30d7\u30ed\u30bb\u30b9ID\u3084\u30d7\u30ed\u30bb\u30b9\u540d\u3068\u5236\u9650\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3067\u52d5\u4f5c\u3057\u307e\u3059\uff0e
\ncat \u304b\u3089\u306f\u3058\u307e\u308b\u30d7\u30ed\u30bb\u30b9\u309250%\u306b\u5236\u9650$ pgrep ^cat | xargs -n1 -I{} sh -c \"cpulimit -p {} -l 50 -v &\"\ncpulimit\u306750%\u306b\u5236\u9650\u3057\u3066\u307f\u305ft\u9803\u6e29\u5ea6\u304c\u4e0b\u304c\u308b\u306e\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3057\u305f\uff0e\u6570\u65e5\u52d5\u304b\u3057\u3066\u3082\u56fa\u307e\u3089\u306a\u304f\u306a\u3063\u305f\u3088\u3046\u3067\u3059\uff0e
\n\u5b9a\u671f\u7684\u306bSoC\u306e\u6e29\u5ea6\u3092\u78ba\u8a8d\u3057\u3066\u5236\u9650\u3092\u5909\u66f4\u3057\u3066\u3044\u304f\u3068\u826f\u3055\u305d\u3046\u3067\u3046s\uff0e
LimitCPU\u306fCPUlimit\u306e\u958b\u767a\u304c\u6b62\u307e\u3063\u305f\u5f8c\u306e\u30d5\u30a9\u30fc\u30af\u3067\u3059\u304c\uff0c\u305d\u306e\u5f8cCPUlimit\u304c\u65b0\u3057\u304f\u958b\u767a\u304c\u59cb\u307e\u3063\u3066\u3044\u308b\u3088\u3046\u3067\u3059\uff0e\u8a73\u7d30\u306f\u4ee5\u4e0b\u306e\u30da\u30fc\u30b8\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\uff0e
\nLimitCPU\u304c\u52b9\u3044\u305f\u306e\u3067\u6050\u3089\u304fcgroup\u3067\u306eCPU\u30ea\u30bd\u30fc\u30b9\u5236\u9650\u3067\u3082\u5927\u4e08\u592b\u305d\u3046\u3067\u3059\uff0e(\u672a\u78ba\u8a8d)
\n\u73fe\u5728\u306f\u6c17\u6e29\u3082\u4e0b\u304c\u308a\u5236\u9650\u306a\u3069\u3057\u306a\u304f\u3066\u3082\u554f\u984c\u3042\u308a\u307e\u305b\u3093\uff0e\u3067\u3082\u304d\u3063\u3068\u6765\u590f\u306b\u307e\u305f\u8d77\u3053\u308b\u3068\u601d\u3046\u306e\u3067\u305d\u3053\u3067\u307e\u305f\u78ba\u8a8d\u3059\u308b\u3064\u3082\u308a\u3067\u3059\uff0e
\n\u3057\u304b\u3057\uff0c\u4eca\u56de\u306e\u89e3\u6c7a\u65b9\u6cd5\u306fCPU\u306e\u30ea\u30bd\u30fc\u30b9\u3092\u5236\u9650\u3057\u3066\u6e29\u5ea6\u3092\u4e0b\u3052\u3066\u5c45\u308b\u306e\u3067\u8a08\u7b97\u91cf\u306f\u6e1b\u3063\u3066\u3044\u307e\u3059\uff0e\u7a7a\u8abf\u3092\u5165\u308c\u305f\u308aCPU\u30d5\u30a1\u30f3\u3092\u5c0e\u5165\u3059\u308b\u306e\u304c\u6b63\u653b\u6cd5\u306b\u306a\u308b\u306e\u304b\u306a\u3068\u601d\u3044\u307e\u3059\uff0e
\nCPU\u30d5\u30a1\u30f3\u306f\u30b5\u30fc\u30c9\u30d1\u30fc\u30c6\u30a3\u30fc\u304b\u3089\u5404\u7a2e\u767a\u58f2\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u305d\u308c\u3089\u3092\u4f7f\u3046\u304bDIY\u3059\u308b\u611f\u3058\u306b\u306a\u308b\u3068\u601d\u3044\u307e\u3059\uff0e
\u305d\u3046\u3044\u3048\u3070\u6700\u8fd1Raspberry Pi OS\u306e\u8a2d\u5b9a\u30b3\u30de\u30f3\u30c9\u306e raspi-config \u306e\u4e2d\u306b Set behaviour of GPIO fan \u3068\u3044\u3046\u30e1\u30cb\u30e5\u30fc\u304c\u51fa\u6765\u305f\u308a\uff0cRaspberry Pi 4\u306b\u306f\u516c\u5f0f\u306eCPU\u30d5\u30a1\u30f3\u304c\u767a\u58f2\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3053\u308c\u3089\u3092\u4f7f\u3046\u306e\u304c\u826f\u3055\u305d\u3046\u3067\u3059\uff0e
\u5148\u65e5mysqldump + xz \u5727\u7e2e\u306e\u9593\u306b pv \u3092\u631f\u3093\u3067\u5e2f\u57df\u5236\u9650\u3092\u3057\u3066 xz \u306e\u8ca0\u8377\u3092\u4e0b\u3052\u307e\u3057\u305f\uff0e
\u3057\u304b\u3057\u3053\u306e\u65b9\u6cd5\u3067\u306f\u305d\u3093\u306a\u306b\u8ca0\u8377\u304c\u306a\u3044 mysqldump \u3082\u305a\u3063\u3068\u52d5\u304b\u3057\u3063\u3071\u306a\u3057\u3067 db \u306b\u3082\u3088\u308d\u3057\u304f\u7121\u3044\u3067\u3059\uff0emysqldump \u306f\u5148\u306b\u6e08\u307e\u305b\u3066 xz \u3060\u3051\u3092\u5236\u9650\u3059\u308b\u3053\u3068\u306b\u3057\u307e\u3059\uff0e
\numask 0266 && nice -n 19 ionice -c 3 /usr/bin/mysqldump --defaults-file=/mnt/backup/micro/.my-backup.cnf --single-transaction --quick --all-databases --events | pv -L 128k 2>/dev/null | nice -n 19 ionice -c 3 /usr/bin/xz -9 > /mnt/backup/micro/`date +\\%F_\\%T_$$`.sql.xz\n
DUMP=\"/mnt/backup/micro/`date +\\%F_\\%T_$$`.sql\"; umask 0266 && nice -n 19 ionice -c 3 /usr/bin/mysqldump --defaults-file=/mnt/backup/micro/.my-backup.cnf --single-transaction --quick --all-databases --events > ${DUMP} && pv -L 128k nice -n 19 ionice -c 3 /usr/bin/xz -9 > ${DUMP}.xz && rm ${DUMP}\n\u4e00\u5fdc\u52d5\u304f\u3051\u3069crontab\u306a\u306e\u3067\uff11\u884c\u3067\u66f8\u3044\u3066\u3042\u3063\u3066\u898b\u306b\u304f\u3044\u3057\u3042\u307e\u308a\u3044\u3051\u3066\u306a\u3044\u3067\u3059\u306d\uff0e
\n\u305b\u3081\u3066\u30d5\u30a1\u30a4\u30eb\u306b\u5206\u3051\u305f\u307b\u3046\u304c\u826f\u3055\u305d\u3046\uff0e
pv\u3067\u3082\u3044\u3044\u306e\u3067\u3059\u304c\uff0ccpu\u5229\u7528\u7387\u3092\u5236\u9650\u3067\u304d\u306a\u3044\u304b\u306a\u3068\u601d\u3044\u307e\u3057\u305f\uff0exz\u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u3067\u306f\u898b\u5f53\u305f\u3089\u305aLinux\u74b0\u5883\u306a\u306e\u3067 cgroups \u3067\u5236\u9650\u3057\u3088\u3046\u304b\u3068\u3082\u601d\u3063\u305f\u306e\u3067\u3059\u304c\uff0c LimitCPU \u3068\u3044\u3046\u3082\u306e\u3092\u898b\u3064\u3051\u307e\u3057\u305f\uff0e\u3053\u308c\u306f SIGSTOP \u3068 SIGCONT \u306ePOSIX\u30b7\u30b0\u30ca\u30eb\u3092\u30d7\u30ed\u30bb\u30b9\u306b\u9001\u4fe1\u3059\u308b\u3053\u3068\u306b\u3088\u308a\u5b9f\u73fe\u3057\u3066\u3044\u308b\u306e\u3067\uff0cPOSIX\u74b0\u5883\u306a\u3089\u3069\u3053\u3067\u3082\u52d5\u304d\u305d\u3046\u306a\u306e\u3067\u3053\u3061\u3089\u3092\u8a66\u3057\u3066\u307f\u307e\u3057\u305f\uff0e
LimitCPU\u306f\u30e1\u30f3\u30c6\u3055\u308c\u306a\u304f\u306a\u3063\u305fCPUlimit\u306e\u30d5\u30a9\u30fc\u30af\u3067\u30b3\u30de\u30f3\u30c9\u3084\u30d1\u30c3\u30b1\u30fc\u30b8\u540d\u306f cpulimit \u3067\u3059\uff0e(\u6df7\u4e71\u3059\u308b><)
$ sudo apt install cpulimit\n
$ cpulimit -h\r\nCPUlimit version 2.1\r\nUsage: cpulimit TARGET [OPTIONS...] [-- PROGRAM]\r\n TARGET must be exactly one of these:\r\n -p, --pid=N pid of the process\r\n -e, --exe=FILE name of the executable program file\r\n The -e option only works when\r\n cpulimit is run with admin rights.\r\n -P, --path=PATH absolute path name of the\r\n executable program file\r\n OPTIONS\r\n -b --background run in background\r\n -c --cpu=N override the detection of CPUs on the machine.\r\n -l, --limit=N percentage of cpu allowed from 1 up.\r\n Usually 1 - 200, but can be higher\r\n on multi-core CPUs (mandatory)\r\n -q, --quiet run in quiet mode (only print errors).\r\n -k, --kill kill processes going over their limit\r\n instead of just throttling them.\r\n -r, --restore Restore processes after they have\r\n been killed. Works with the -k flag.\r\n -s, --signal=SIG Send this signal to the watched process when cpulimit exits.\r\n Signal should be specificed as a number or\r\n SIGTERM, SIGCONT, SIGSTOP, etc. SIGCONT is the default.\r\n -v, --verbose show control statistics\r\n -z, --lazy exit if there is no suitable target process,\r\n or if it dies\r\n -- This is the final CPUlimit option. All following\r\n options are for another program we will launch.\r\n -h, --help display this help and exit\n
\u5236\u9650\u306f\u30d7\u30ed\u30bb\u30b9ID\u3067\u306e\u5236\u9650\uff0c\u30d7\u30ed\u30b0\u30e9\u30e0\u540d\u3067\u306e\u5236\u9650\uff0c\u6307\u5b9a\u3057\u305f\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u5236\u9650\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\uff0e
\ncpu\u304c\u8907\u6570\u3042\u308b\u5834\u5408\u306f -l \u306e\u5024\u306fcpu 1\u3064\u3042\u305f\u308a100\u3068\u3057\u3066\uff0c100 * cpu\u6570 \u3092\u5143\u306b\u6307\u5b9a\u3057\u307e\u3059\uff0ecpu 2\u3064\u3067 50% \u5229\u7528\u3057\u305f\u3044\u5834\u5408\u306f -l 100 \u306b\u306a\u308b\u3068\u601d\u3044\u307e\u3059\uff0e
1234 \u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u3092cpu\u30922\u3064\u5229\u7528\uff0c\uff43\uff50\uff55\u309250%(2\u30b3\u30a2\u306a\u306e\u3067\u5b9f\u969b\u306f100%\u5206)$ cpulimit -c 2 -p 1234 -l 50\n
$ cpulimit -c 2 -l 50 - xz\n
\u203bxz\u306e\u524d\u306e - \u306f\u306a\u304f\u3066\u3082\u3044\u3044\u304c cpulimit \u306e\u30aa\u30d7\u30b7\u30e7\u30f3\u306e\u6700\u5f8c\u3092\u793a\u3059\uff0e
$ cpulimit -c 1 -l 25 -z - xz -9 datafile\n
-c : \u5229\u7528\u3059\u308b\uff43\uff50\uff55\u6570
\n-p : \u5236\u9650\u3059\u308b\u30d7\u30ed\u30bb\u30b9ID
\n-l : \u5236\u9650\u3059\u308bcpu\u5229\u7528\u7387
\n-z : \u6307\u5b9a\u3057\u305f\u30d7\u30ed\u30bb\u30b9\u304c\u5b8c\u4e86\u3057\u305f\u3089cpulimit\u3082\u7d42\u4e86\u3059\u308b(\u901a\u5e38\u306f\u95a2\u3057\u3092\u7d9a\u3051\u3066\u540c\u3058\u6761\u4ef6\u306b\u4e00\u81f4\u3059\u308b\u30d7\u30ed\u30bb\u30b9\u304c\u73fe\u308c\u305f\u3089\u5236\u9650\u3059\u308b)
\n\u4eca\u56de\u306fxz\u3092\u5236\u9650\u3057\u305f\u3044\u306e\u3067\u3053\u3093\u306a\u611f\u3058\u306b\uff0e
\n\u3042\u307e\u308a\u5909\u308f\u308a\u307e\u305b\u3093\u306d\u2026\u2026\uff0e
DUMP=\"/mnt/backup/micro/`date +\\%F_\\%T_$$`.sql\"; umask 0266 && nice -n 19 ionice -c 3 /usr/bin/mysqldump --defaults-file=/mnt/backup/micro/.my-backup.cnf --single-transaction --quick --all-databases --events > ${DUMP} && nice -n 19 ionice -c 3 cpulimit -c1 -l 25 - /usr/bin/xz -9 ${DUMP}\n\u30d0\u30c3\u30af\u30a2\u30c3\u30d7\u5c02\u7528\u30e6\u30fc\u30b6\u3068\u3057\u3066\u5206\u3051\u3066\u3042\u308b\u306e\u3067\u305d\u306e\u30e6\u30fc\u30b6\u3067 cpulimit -c 1 -l 25 - xz \u3068\u304b\u3057\u3066xz\u3068\u3044\u3046\u540d\u524d\u306e\u30d7\u30ed\u30bb\u30b9\u3092\u5168\u90e8\u5236\u9650\u3057\u3066\u3057\u307e\u3046\u306e\u3082\u3042\u308a\u304b\u3082\u3057\u308c\u307e\u305b\u3093\uff0emonit \u3068\u304b\u3067\u76e3\u8996\u3055\u305b\u308c\u3070\u3044\u3044\u611f\u3058\u304b\u3082?\u305d\u3046\u3059\u308b\u3068\uff0c
DUMP=\"/mnt/backup/micro/`date +\\%F_\\%T_$$`.sql\"; umask 0266 && nice -n 19 ionice -c 3 /usr/bin/mysqldump --defaults-file=/mnt/backup/micro/.my-backup.cnf --single-transaction --quick --all-databases --events > ${DUMP} && /usr/bin/xz -9 ${DUMP}\n\u3042\u307e\u308a\u5909\u308f\u308a\u307e\u305b\u3093\u306d\u2026\u2026\uff0e
\n$ dpkg-query -W cpulimit xz-utils\r\ncpulimit 2.2-1\r\n$ lsb_release -d\r\nDescription: Ubuntu 16.04.5 LTS\r\n$ uname -m\r\nx86_64\n