Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A very simple question

Status
Not open for further replies.

calinserban

Programmer
Nov 8, 2002
1
CA

I'm not a shell script programmer, so the question it might look like one for a first student grade.
I have been asked 2 days ago to write an AIX script to start up or shut down some specific processes at one time. Everything looks OK, excepting that I want to make sure that in case the "start up" option is chosen, those specific processes are not running. To be more specific, I will take only one process, say "omni". I declared a variable
OMNI_PID=$(ps -eaf | grep omni | grep -v grep | awk '{print substr($2,1,20);}'), and I want to test if that process is running, but I don't know what it returns if the service is not running:
if [ $OMNI_PID != null ]
then
echo " The OMNI services are running in the system."
else
echo " Starting RMI services"
nohup omniNames &
fi
When the process is running, I'm getting a 5 digits number, but when not, I don't have a clue what I should put in the if statement.
Any help would be appreciated.

Thanks

 
Perhaps it would be simpler to test what a simple ps -ef returns. Something like:

ps -ef | grep -v grep | grep omni

will return a value (test for this using $?) of 1 if the process isn't found and 0 (zero) if it is. It's then just a matter of deciding what to do in either event. Post bac if you require more details. HTH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top