cpulimit は実際に CPU 使用量を制限しません。

cpulimit は実際に CPU 使用量を制限しません。

私は次cpulimitのように始めましたcron

00 16 * * * /usr/bin/cpulimit --limit 20 /bin/sh /media/storage/sqlbackup/backups.sh

操作が開始されると、通常どおりCPUが急増し、ビープ音が鳴りますが、実際に識別可能な調整は発生しません。タスク自体は多くのサブディレクトリで構成されたディレクトリを繰り返し実行し、実行されるたびにこれがサブrsyncプロセスrsyncを生成すると思います(実行の上部にはrsync呼び出しに使用できるpidがあり、数分後に別のpidがあるでしょうrsync)。

cpulimitこのプロセスで消費される使用量を効果的に制限するために、それを適切に活用する方法がわかりません。

これは、2G RAMと1vCPUを搭載した仮想マシンであることを覚えておくことが重要です。

ベストアンサー1

cpulimitサブプロセスは基本的に制限されないため、rsyncまったく制限されません。新しいバージョンを実行する場合(または)オプションをcpulimit使用できます。 (あなたも見ることができます--include-children-iこの回答.)

$ cpulimit -h
Usage: cpulimit [OPTIONS...] TARGET
   OPTIONS
      -l, --limit=N          percentage of cpu allowed from 0 to 400 (required)
      -v, --verbose          show control statistics
      -z, --lazy             exit if there is no target process, or if it dies
      -i, --include-children limit also the children processes
      -h, --help             display this help and exit
   TARGET must be exactly one of these:
      -p, --pid=N            pid of the process (implies -z)
      -e, --exe=FILE         name of the executable program file or path name
      COMMAND [ARGS]         run this command and limit it (implies -z)

Report bugs to <[email protected]>.

これにより、cronエントリは次のように変更されます。

00 16 * * * /usr/bin/cpulimit --include-children --limit 20 /bin/sh /media/storage/sqlbackup/backups.sh

cpulimit編集:OP(自己)が答えたように、スクリプト内のコマンドに対しては機能しますが、rsync他の機能を実行するときにスクリプトが良いという保証はありません。たとえば、スクリプトが多数のディレクトリを処理する必要がある場合、システムが輻輳して CPU スパイクや警告が発生する可能性があります。

おすすめ記事