2

I am trying to find a way to make an existing (proprietary) linux process to consume high amount of CPU or make it so busy that it would stop responding to an other process but do not respawn.

All I have at the moment is its pid in user space. Maybe some kind of super fast ping to the process may do the work. Forgive my limited knowledge.

user5071535
  • 1,312
  • 8
  • 25
  • 42
  • If you test the process in a VM with very limited resources, does it help? – hek2mgl Jul 23 '15 at 12:25
  • under windows you can make a :1 goto 1 batch that would use 100%. in linux maybe the same way ? – Chaka Jul 23 '15 at 12:31
  • 1
    I think it would help to know *why* you want an existing process to use a lot of CPU. There are plenty of technical solutions to that question, but I really think there should be no technical reason to ask that question. – BraveNewCurrency Jul 23 '15 at 23:28

1 Answers1

3

Rather than try to spike the cpu usage, you could try to starve it of cpu time, thus preventing it from responding to the other process.

Since you know the process id, you can reduce its access to cpu time by using cpulimit.

Example: The following command should allow process 1234 only 1% of the cpu.

cpulimit --pid=1234 --limit=1

If this doesn't slow it down enough, you could also try bogging down the cpu by running other cpu-intensive applications in conjunction with using cpulimit.

[EDIT]

Since you don't have cpulimit on your system, you could use SIGSTOP and SIGCONT instead (which is what cpulimit uses anyway I believe):

kill -SIGSTOP [pid]
kill -SIGCONT [pid]

If your system doesn't recognize the -SIGSTOP and -SIGCONT, you could use their IDs directly:

kill -19 [pid]
kill -18 [pid]
user5071535
  • 1,312
  • 8
  • 25
  • 42
  • I am looking exactly something like this but I do not have cpulimit utility in my server, otherwise it would be a perfect answer. Thanks –  Jul 24 '15 at 06:56
  • @user2809888: I edited my answer with an alternate method using kill since you don't have access to cpulimit. This way should be better for your needs since your can actually stop the process rather than just throttling it down to 1% – user5071535 Jul 27 '15 at 19:18