Script to check process status

Hi Team,
I am using redhat 6.4 version server.We have a script which is used to check the process and sends email if the process is not running.If it is running it will continue and do some other operation.

I didnot understand below option -z in the if condition.I have tried to search in the net for the same but didnot get any related explanation on this.

if [[ -z `ps -ef | grep /usr/sbin/sshd` ]];then
   echo;echo "The ssd  is not running; exiting."
   exit
fi

My intention here is if the process is not running it should exit from the script and should send an email to the distribution list.It should not continue and do the next tasks if the process is not running.

thanks for your replies.

Regards,
Murali

man bash :

Thanks Rudi for your response.But i could see eventhough the ssh process is running it it saying process is not running.Is the above code has any issues?

thanks

Works for me as is. Try to run it with the xtrace option set. Post the output.

I don't see your reported problem, but pgrep solves some potential problems

if [[ -z `pgrep -u 0 -x sshd` ]];then

Thanks for your replies.I am able to execute this script.