0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

nohupとniceを同時に使う

Last updated at Posted at 2021-06-14

nohup, nice の併用

nohup でジョブを投げつつ、優先度を指定したい場合は、例えば下記のようにする。

$ nohup nice -n 19 python test.py > R_out.log 2> R_err.log < /dev/null &

なお、 nice -n [N] におけるNice [N] は数字が小さいほど優先度が高い。
「-20から20」の範囲で選べる。「19」は優先度がかなり低い。

実際の運用

  • 88CPUのマシン
  • 50個がすでに他のジョブで占有されている(Nice = 0)
  • さらに50個を別のジョブとして投げる(Nice = 19)

というのをやって見たところ、

  • 50 CPU ... 100% (Nice = 0)
  • 26 CPU ... 100% (Nice = 19)
  • 24 CPU ... 50% (Nice = 19)

となり、合計すると大体 8,800% [つまり88個のCPU = 50+26+(24/2)]となった。

$ top
top - 09:16:30 up 15:02,  1 user,  load average: 100.06, 100.05, 100.00
Tasks: 993 total, 101 running, 490 sleeping,   0 stopped,   0 zombie
%Cpu(s): 56.8 us,  0.0 sy, 43.1 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem : 19664990+total, 18852203+free,  4820816 used,  3307060 buff/cache
KiB Swap:  2097148 total,  2097148 free,        0 used. 19037852+avail Mem 
                      
  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                         
16376 user_01   20   0  374584  95984  12600 R 100.0  0.0 111:32.88 python 
16393 user_01   20   0  374584  96256  12820 R 100.0  0.0 111:33.50 python 
...(中略)
16548 user_01   39  19  417500 137744  18928 R  99.7  0.1  52:56.54 python 
16550 user_01   39  19  374588  95656  12296 R  99.7  0.0  95:02.91 python 
...(中略)
16564 user_01   39  19  419628 140060  18928 R  52.1  0.1  80:16.57 python 
16554 user_01   39  19  417512 138016  18932 R  50.2  0.1  75:49.32 python 

よくみると、PR(Priority優先度)はデフォルトで20で、PR = 20 + NI(Nice) となっている。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?