0

Do background process have different nice given? I noticed it is not having the default 0. This might be a problem because it is having less priority.. does anyone know how to change this behavior? I run the java via below start script and no there is no nice called inside that script.

nohup ./start.sh &

F S   UID    PID   PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
0 S  5330  12759      1  0  84   4 -  3283 -      ?        00:00:00 start.sh
0 S  5330  12772  12759  1  84   4 - 1462473 -    ?        00:19:12 java
6
  • What shell are you using? The ksh shell has a bgnice shell option that, when it is set, means that any background job will have a nicer niceness value. – Kusalananda Apr 12 '20 at 22:07
  • The user is using ksh but i explicitly use #!/bin/sh in the script. – Ykaly Apr 12 '20 at 22:13
  • Are they maybe either starting the script as ksh ./thescript or maybe as ./thescript &? – Kusalananda Apr 12 '20 at 22:19
  • Well not exactly like that. It is being started as nohup ./thescript &. – Ykaly Apr 12 '20 at 22:22
  • 1
    Does this validate what you're saying? user@server:/home/user> set -o | grep bgnice bgnice on – Ykaly Apr 12 '20 at 22:28
1

The user running this script is starting it in the background from an interactive ksh shell session.

The ksh shell has a shell option called bgnice, which in ksh93 is on by default, which causes the shell to start background jobs with a non-zero niceness value (it will be 4 higher than the shell the job is started from).

This is from the ksh93 manual:

bgnice All background jobs are run at a lower priority. This is the default mode.

To turn this option off, use

set +o bgnice

In some variants of the ksh shell (e.g. pdksh, and possibly mksh), the option is still available, but not set by default.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.