(O+P)ut

アウトプット



(O+P)ut

エンジニアのアウトプット

【Linux】CPU負荷率を上げるyesコマンド

スポンサーリンク

やりたいこと

CPUの閾値監視メッセージの確認のため、Linux機においてCPU負荷率を明示的に上げたい。

使えるコマンド

yesコマンドを用いて

$ which yes
/usr/bin/yes

以下のように/dev/nullに出力する。

$ yes > /dev/null &

以下、補足です。

補足

‘yes’: Print a string until interrupted
============================================
‘yes’ prints the command line arguments, separated by spaces and followed by a newline, forever until it is killed.  If no arguments are given, it prints ‘y’ followed by a newline forever until killed.

要は画面に「y」を出力するコマンドです。

プロセスを落とすまで以下のように

$ yes
y
y
y
y
y
y
y
y
y
y
y
y
y
...

と標準出力を続けます。

落とし方はプロセスコマンドでIDを確認して

$ ps -ef
     UID     PID    PPID  TTY        STIME COMMAND
...
AzureAD+    2007    1930 pty1     14:56:07 /usr/bin/yes
...

killします。

$ kill 2007

もちろん、上限に抵触するまで複数起動可能です。

以上、ご参考になれば幸いです。