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.