High load - Process eats CPU when run from script

  • flocsy
  • Born
  • Born
  • User avatar
  • Posts: 4

Post 3+ Months Ago

I have a java program that listens on a port and updates a mysql table when it receives signals. Tere are 1-10 signals/sec.

The program works well it uses less than 5% CPU when I run it this way from shell:

--------------------------------------------------------
./signal -q Pro >> /tmp/signal.log &
--------------------------------------------------------

But when I run it from a shell script it uses around 75% CPU. I can reproduce it, it makes this 100% of the times when I run it this way.

Here's the script:
--------------------------------------------------------
#!/bin/sh
cd /home/fxyard/bin
SI=`ps ax | grep "java Signal" | grep -v grep`
if [ x"$SI" = x"" ] ; then
echo "Restarting" `date` >> /tmp/signal.log
./signal -q Pro >> /tmp/signal.log &
fi
--------------------------------------------------------

As you see the signal is invoked the same way from the shell, from the shell script. And I invoke this scipt from the same shell session:

./signal-script


Any idea why it eats my CPU? What should I change?
What should I check?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Daemonguy
  • Moderator
  • Web Master
  • User avatar
  • Posts: 2700
  • Loc: Somewhere outside the box in Sarasota, FL.

Post 3+ Months Ago

Is it consistently starting many instances of that command? Despite being present in the ps?
  • bttk
  • Born
  • Born
  • bttk
  • Posts: 4

Post 3+ Months Ago

do not grep "java Signal"

grep signal
  • flocsy
  • Born
  • Born
  • User avatar
  • Posts: 4

Post 3+ Months Ago

Daemonguy: no, it only runs once. That part of the scipt works ok. It actually runs from cron and that's why it checks it via ps.

bttk: no that doesn't work, 'cause signal is a script that sets the CLASSPATH and then
exec java Signal "$@"

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: No registered users and 86 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.