[CentOS] System V Init Script
John R. Dennison
jrd at gerdesas.com
Wed Jun 3 09:42:09 UTC 2009
On Wed, Jun 03, 2009 at 10:29:08AM +0100, James Bensley wrote:
>
> restart)
> echo -n "Stopping my_app: "
> pgrep my_app | while read PIDS; do # I have chosen this method because
> my_app spawns various child processes
> kill -9 $PIDS # and they all need to DIE!
> (Killing the parent process would kill the child processes
> done # however there are
> actually two parent processes so this seems like a good idea?)
> echo -n "Starting my_app: "
> /usr/local/my_app/sbin/my_app_bin &
> exit $?
> ;;
I'd think that the pgrep is matching both the processes you want
to kill _and_ the init.d script itself. Try "pgrep -x" which
will exactly match the specified command.
Even better, use "pkill -x -9 my_app" which will combine the
grep and kill tasks in a single command; the -9 specifies the
signal to send to the matches processes.
"man pgrep" for more information on both commands.
John
--
"I'm sorry but our engineers do not have phones."
As stated by a Network Solutions Customer Service representative when asked to
be put through to an engineer.
"My other computer is your windows box."
Ralf Hildebrandt
<sxem> trying to play sturgeon while it's under attack is apparently not fun.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://lists.centos.org/pipermail/centos/attachments/20090603/0ab21e2c/attachment.sig>
More information about the CentOS
mailing list