HPE Community read-only access December 15, 2018
This is a maintenance upgrade. You will be able to read articles and posts, but not post or reply.
Hours:
Dec 15, 4:00 am to 10:00 am UTC
Dec 14, 10:00 pm CST to Dec 15, 4:00 am CST
Dec 14, 8:00 pm PST to Dec 15, 2:00 am PST
cancel
Showing results for 
Search instead for 
Did you mean: 

Script help

 
Soul_1
Respected Contributor

Script help

Hi,

I need one script for.

First it need to check one service.If that service is not running,it should execute a command.

1. ovstatus -c
2. not running then start ovstart -c
3. if running then exit.

Please help me

Thanks in advance
3 REPLIES
OldSchool
Honored Contributor

Re: Script help

what would "ovstatus -c" return if the services is running? Not running?
Rick Garland
Honored Contributor

Re: Script help

What service would you be checking to see if it is running? How would you check to see if that service is running? (ps, top, some other command, etc.)
Viktor Balogh
Honored Contributor

Re: Script help

you could try this:

# PROCESS=inetd;ps -ef | grep -v grep | grep -q $PROCESS && echo "BINGO!"
BINGO!
#

# PROCESS=no_such_process;ps -ef | grep -v grep | grep -q $PROCESS && echo "BINGO!"
#

replace 'echo "BINGO!"' with your 'ovstart -c' command, and give the PROCESS variable the name of the process you want to check. Be sure that it is unique in the 'ps -ef' output!
****
Unix operates with beer.