Operating System - Linux
1752786 Members
6132 Online
108789 Solutions
New Discussion юеВ

Re: shell script for tracking processes

 
SOLVED
Go to solution
Bill Hassell
Honored Contributor

Re: shell script for tracking processes

The -C option provides an exact process name match. So if you were looking for /usr/bin/vi, the command would be:

UNIX95= ps -f -C vi

and to store the results of the ps search:

MYSTATUS=$(UNIX95= ps -f -C vi)
echo $MYSTATUS

Be sure you do not put a pathname (ie, -C /usr/bin/vi) because that is not the process name. The process name is just the last part of a pathname.


Bill Hassell, sysadmin
paolo barila
Valued Contributor

Re: shell script for tracking processes

Hi,

check it out also

# ps -efx | grep

to see all parameters of a process running,

very useful with java processes.


Pablo
share share share
Steven E. Protter
Exalted Contributor

Re: shell script for tracking processes

Shiv,

I agree with Bill. JRF's script is the most elegant and efficient because it does it all on one line.

Note:
Do not set the UNIX95 variable by default in /etc/profile, .profile or other profiles, unless you create a special user for this.

A VERY common gotcha is setting this variable by default. It interferes with SD/UX when you sh a patch depot, it triggers checksum failures.

I will admit that I fell victim to this very mistake some years ago.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Tom Satinet
Frequent Advisor

Re: shell script for tracking processes

Hi,

This is great. I have got this working now. We have a stupid electronic invoicing system that send out emails. but it dies if it looses connection to the smtp server even for a second. don't ask why it can't wait..... p poor code....

anyway, I think i will run this in a start up script and monitor the process. Thanks for the warning on UNIX95. i think i will just run this as root, but set the variable in the script.

many thanks:-D