#!/bin/sh # 检查客户端和服务端端口是否存在 #存在返回0否则返回1 source /app/riskenv log=/var/log/checkPort.log function foo() { echo $1>>$log } function test(){ check=0 foo "=====================start check=====================" if [ -z "`/app/findPortPid $PORT`" ] then foo "server status:stop" check=1 else foo "server status:start" fi if [ -z "`/app/findPortPid $clientPort`" ] then foo "client status:stop" check=1 else foo "server status:start" fi if [ $check -eq 0 ] then foo "server and client is running" return 0 else return 1 fi } test echo $?