3

We have a Linux server with multiple users logged in. If someone runs make -jN it hogs the whole server CPU usage and responsiveness to other users decreases drastically.

Is there any way to decrease the priority of make process run by anyone in Linux?

manav m-n
  • 11,136
  • 23
  • 74
  • 97

2 Answers2

3

Make has a '-l' (--load-average) option. If you specify 'make -l 3', make will not launch additional jobs if there are already jobs running and the load is over 3.

From the manpage:

   -l [load], --load-average[=load]
        Specifies that no new jobs (commands) should be started  if  there
        are  others  jobs running and the load average is at least load (a
        floating-point number).  With no argument, removes a previous load
        limit.

It doesn't really decrease the priority of make, but it can avoid causing too much load.

Mathiasdm
  • 1,791
  • 14
  • 26
1

replace make with your own script and add a "nice -n <>" command, so that higher the -jN, more the niceness.

start a super-user process that does ps -u "user name" | grep make, and count the number of processes. use renice on the process ids make them in line, or any other algorithm you want

Nish
  • 379
  • 2
  • 9
  • Not a clean solution, as multiple users are involved and make arguments are auto-generated from configure/automake tools – manav m-n Jun 25 '14 at 07:31
  • @Manav: that is not a problem. – reinierpost Jun 25 '14 at 08:09
  • 1
    The problem is that the original make will still need to be called, but people can then call it directly. – reinierpost Jun 25 '14 at 08:10
  • 1
    Now you have two answers in one. The problem with the second answer is that you'll be renicing make but not the processes that do the actual work. – reinierpost Jun 25 '14 at 08:30
  • you can renice all processes by the user, assuming build is the only thing they do using "renice -u " – Nish Jun 25 '14 at 08:36
  • @Nish: If you renice everything, the relative priorities do not change and nothing improves. The whole reason for `nice` is to change relative priorities by being selective. – MSalters Jun 25 '14 at 09:02