即使脚本成功运行,仍会显示错误状态

即使脚本成功运行,仍会显示错误状态
#!/bin/sh
serverStatus=$(ps aux | grep server1 -c)
serverStop='/server/myscripts/stopServer.sh server1'
serverStart='/server/myscripts/startServer.sh server1'

$serverStop
sleep 60

echo "$serverStatus"  

if [ $serverStatus -ne 2 ]
then
        echo 'Alert: App Server1 is down'
        
                $serverStart

else
        echo 'Alert: App Server1 is up and running'
        
fi

输出:

ADMU0116I: Tool information is being logged in file
           /server/myscripts/logs/server1/stopServer.log
ADMU0128I: Starting tool with the server profile
ADMU3100I: Reading configuration for server: server1
ADMU3201I: Server stop request issued. Waiting for stop status.
ADMU4000I: Server server1 stop completed.

2

Alert: App Server1 is up and running

输出应该是:

ADMU0116I: Tool information is being logged in file
           /server/myscripts/logs/server1/stopServer.log
ADMU0128I: Starting tool with the server profile
ADMU3100I: Reading configuration for server: server1
ADMU3201I: Server stop request issued. Waiting for stop status.
ADMU4000I: Server server1 stop completed.

1

Alert: App Server1 is down

相关内容