FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora User

 
 
LinkBack Thread Tools
 
Old 08-25-2008, 01:02 PM
James Pifer
 
Default service; ps & grep help

I could use a little help with ps and grep. When running a command like:

# ps -ewf | grep sendmail
root 2730 1 0 Jul14 ? 00:00:01 sendmail: accepting connections
smmsp 2739 1 0 Jul14 ? 00:00:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
root 6500 6362 0 07:51 pts/3 00:00:00 grep sendmail

Is there any way to run this command and get these results, but exclude
the actual grep itself, which is the last line?

A little background, I have a java based application that I've used a
custom start and stop script for. Basically the stop script does:
stop() {
for pid in `ps -efww | grep myapp | grep -v grep | cut -b 10-15`;do
#echo $pid
kill -9 $pid
done
RETVAL=$?
return $RETVAL
}

This has worked for years, but for some reason it has stopped working. I
think it may be because the process is killing itself before it kills
the app?

I assume the correct way to do this is store the pid in a file that you
reference, but I haven't figured out how to do that yet.

Any help is appreciated.

Thanks,
James


--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 08-25-2008, 01:14 PM
g
 
Default service; ps & grep help

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


James Pifer wrote:
> I could use a little help with ps and grep. When running a command like:
>
> # ps -ewf | grep sendmail

# ps -ewf | grep sendmail | grep -v grep

run 'man grep'

- --
tc,hago.

g
.

in a free world without fences, who needs gates.

learn linux:
'Rute User's Tutorial and Exposition' http://rute.2038bug.com/index.html.gz
'The Linux Documentation Project' http://www.tldp.org/
'HowtoForge' http://howtoforge.com/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Red Hat - http://enigmail.mozdev.org

iD8DBQFIsrAx+C4Bj9Rkw/wRAiQLAKCue/aV+KTpx8avNWtJaO+WO4VudwCgljZK
/hhB1WItU/avJAeW5k7TGFg=
=MWR/
-----END PGP SIGNATURE-----

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 08-25-2008, 01:19 PM
g
 
Default service; ps & grep help

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


g wrote:
>
> James Pifer wrote:
>> I could use a little help with ps and grep. When running a command like:
>
>> # ps -ewf | grep sendmail
>
> # ps -ewf | grep sendmail | grep -v grep
>
> run 'man grep'

oops.

left off, same as in your script.



- --
tc,hago.

g
.

in a free world without fences, who needs gates.

learn linux:
'Rute User's Tutorial and Exposition' http://rute.2038bug.com/index.html.gz
'The Linux Documentation Project' http://www.tldp.org/
'HowtoForge' http://howtoforge.com/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)
Comment: Using GnuPG with Red Hat - http://enigmail.mozdev.org

iD8DBQFIsrFa+C4Bj9Rkw/wRAmafAKCVuuoeGzx617dfTs6uP1Sdc6vEMgCfbPDk
3qwYGa8l9UhLDXnssEBBD+o=
=8QmE
-----END PGP SIGNATURE-----

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 08-25-2008, 01:25 PM
Mogens Kjaer
 
Default service; ps & grep help

James Pifer wrote:
...
> A little background, I have a java based application that I've used a
> custom start and stop script for. Basically the stop script does:
> stop() {
> for pid in `ps -efww | grep myapp | grep -v grep | cut -b 10-15`;do
> #echo $pid
> kill -9 $pid
> done

Can't you add a line with

ps -efww >/tmp/panic1.log

before the "for" line and a

echo $pid >>/tmp/panic2.log

before the kill line and check afterwards what has happened?

Mogens
--
Mogens Kjaer, Carlsberg A/S, Computer Department
Gamle Carlsberg Vej 10, DK-2500 Valby, Denmark
Phone: +45 33 27 53 25, Fax: +45 33 27 47 08
Email: mk@crc.dk Homepage: http://www.crc.dk

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 08-25-2008, 01:28 PM
Anders Karlsson
 
Default service; ps & grep help

* James Pifer <jep@obrien-pifer.com> [20080825 15:03]:
> I could use a little help with ps and grep. When running a command like:
>
> # ps -ewf | grep sendmail
> root 2730 1 0 Jul14 ? 00:00:01 sendmail: accepting connections
> smmsp 2739 1 0 Jul14 ? 00:00:00 sendmail: Queue runner@01:00:00 for /var/spool/clientmqueue
> root 6500 6362 0 07:51 pts/3 00:00:00 grep sendmail

Try
# ps -ef | grep [s]endmail
instead. Should do what you want (does for me anyway).

> Is there any way to run this command and get these results, but exclude
> the actual grep itself, which is the last line?
>
> A little background, I have a java based application that I've used a
> custom start and stop script for. Basically the stop script does:
> stop() {
> for pid in `ps -efww | grep myapp | grep -v grep | cut -b 10-15`;do
> #echo $pid
> kill -9 $pid
> done
> RETVAL=$?
> return $RETVAL
> }

Well, in a shell, $$ is the PID. If you can capture your process PID
when it starts, you simply write it in a file in /var/run/ and when
you stop, you issue a "kill -9 $(</var/run/pidfile)".

> This has worked for years, but for some reason it has stopped working. I
> think it may be because the process is killing itself before it kills
> the app?
>
> I assume the correct way to do this is store the pid in a file that you
> reference, but I haven't figured out how to do that yet.
>
> Any help is appreciated.

You can have a look at various init scripts in /etc/init.d/ to get an
idea about how they done it.

/Anders

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 

Thread Tools




All times are GMT. The time now is 07:42 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org