High load - Process eats CPU when run from script

  • flocsy
  • Born
  • Born
  • User avatar
  • Joined: Dec 07, 2006
  • Posts: 4
  • Status: Offline

Post December 7th, 2006, 6:34 am

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
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post December 7th, 2006, 6:34 am

  • Daemonguy
  • Moderator
  • Web Master
  • User avatar
  • Joined: Jan 23, 2004
  • Posts: 2673
  • Loc: Somewhere outside the box in Sarasota, FL.
  • Status: Offline

Post December 8th, 2006, 6:22 am

Is it consistently starting many instances of that command? Despite being present in the ps?
"It's always a long day, 86,400 won't fit into a short."
  • bttk
  • Born
  • Born
  • No Avatar
  • Joined: Dec 08, 2006
  • Posts: 4
  • Status: Offline

Post December 8th, 2006, 6:59 am

do not grep "java Signal"

grep signal
  • flocsy
  • Born
  • Born
  • User avatar
  • Joined: Dec 07, 2006
  • Posts: 4
  • Status: Offline

Post December 12th, 2006, 2:41 pm

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 57 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
 
cron
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.