Re: service; ps & grep help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





James Pifer wrote:
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


Could it be that the script itself is getting caught in your "ps" and is getting killed (not the grep embedded in the script)? Could it be the "cut" part of the line (we've always used 'awk '{ print $2 }' ' in our stop blocks...never tried the cut idea) that's getting messed up somehow?

Kevin

--
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux