0

We use a VM/server as the jump box to our other servers, it holds all the RSA keys. I keep getting alerts that the CPU is over 75% from VMware. We run 3 bash scripts on there - just general checking to the DB's and perforce. I had noticed when I looked into top, it had a high niceness CPU and system CPU.

enter image description here

I was just wondering, is there any way I can bring them down and hopefully bring down the overall CPU so I don't get the alarms from VMware? I'm not too sure on what to look into on how to do this.

  • Is the issue the warnings from VMware or that the system is actually utilized at above 75%? – Kusalananda Sep 12 '17 at 14:27
  • Looks like some of those shell scripts are doing while true; do thing_that_does_something _short; done. If you add a sleep in the loop, it will use less CPU. – Mark Plotnick Sep 12 '17 at 17:22
  • Thank you for the comments. @Kusalananda - I believe the system is above 75%. – Marc Sep 13 '17 at 8:56
  • @Mark Plotnick - I'm new to bash scripting, where would I add the sleep command? – Marc Sep 13 '17 at 8:56
  • If the ping-to-db.sh script is short and you can remove any sensitive information from it, you can add it to your question and we can offer suggestions. – Mark Plotnick Sep 13 '17 at 19:25
0

If, as Mark Plotnick suggests, the shell scripts are doing something in a tight loop, such as

while true; do
    command_to_do_something
done

(or something equivalent) then this may cause the script to use a lot of system resources in terms of CPU.

The loop can be slowed down by simply inserting a sleep call:

while true; do
    command_to_do_something
    sleep 60
done

This would introduce a 60 second pause during which the script will do absolutely nothing, hence freeing up resources.

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.