ps -ef does not displaying the running process

Hi,

I am using the monitor shell script to check the particular process is running or not.If it is not running this monitor shell script will automatically start the process.I am using the ps -ef command to check the process availablity.But the problem is some times the ps -ef | grep "Process name" is not working(does not displaying anything in the console).so my monitor script assumes that the process is not running and trying to start the process.Is there any other way to ensure the process availablity?

Sorry, I didnot understand the question completely.

If ps -ef | grep processname is not displaying anything, there is no such process currently running or the expected process has finished running by the time, ps did a scan in the process table.

Alternatively, if the system has got a VFS ( virtual fiile system ), check for a directory in the name of process id in /proc/

Hi,
Thanks for your reply.

My problem is eventhough the process is running

ps -ef | grep "process name"

does not displaying the running process name in the console.

that is not possible,
just double checking -

is there any spelling mistake in the process name typed?
are you very sure process is still running?

Maybe below command give you some helps.

/usr/ucb/ps -auwwwx |grep "process name"

I am very mich sure that the process is still running.No spelling mistakes.

---------- Post updated at 02:28 PM ---------- Previous update was at 02:22 PM ----------

I am very mich sure that the process is still running.No spelling mistakes.we are using solaris sparc architecture machine.Also its not happening 99% of the time.

This is a known problem with "ps -ef".
Better to record the PID of the background process when it starts and then only check that PID.
Easier if we can see the script that starts the process and the script that tests whether the process is running.

For checking the process ID ,I have to use ps -ef | grep pid or ps -p pid. What is the assurance that this commands won't fail.Any way its landed up to the same position again right?

Thanks in advance :slight_smile:

Never seen "ps -p PID" misbehave, only "ps -ef" on a heavily loaded system.

I have inherited an alert script which counts one type of process every 5 minutes based on "ps -ef". Every few days the alert fires spuriously with a number too high or too low. If the alert fires again, I look.

My system-supplied standard init scripts mostly use "ps -e" piped to a clever awk to find the PID of a process. Might be worth a trawl through your system's init scripts to see what techniques they use. Personally I would find out the PID at the time of starting the process and record that PID in a file with view to using "ps -p PID".