LSOF命令在crontab中无法执行解决方法

相关shell如下:

#!/bin/bash

#10018_restart

#wyk-20150518

/opt/uniisp/.bash_profile

PID=`ps -ef | grep 10018_sp_client | grep -v grep  | awk '{print $2}' `

echo $PID

#/usr/sbin/lsof -p $PID >> /opt/uniisp/shell/log/test.txt

/usr/sbin/lsof -p $PID | grep "can't" >/opt/uniisp/shell/log/10018.$$ 2>&1

/usr/sbin/lsof -p $PID | grep "identify protocol" >>/opt/uniisp/shell/log/10018.$$ 2>&1

/usr/sbin/lsof -p $PID | grep "can't identify" >>/opt/uniisp/shell/log/10018.$$ 2>&1

/usr/sbin/lsof -p $PID | grep "identify" >>/opt/uniisp/shell/log/10018.$$ 2>&1

sleep 10

#ps -ef | grep 10018_sp_client | grep -v grep  | awk '{print $2}' | xargs -n 1 -i lsof -p {}  >/opt/uniisp/shell/log/1001801

if [  -s /opt/uniisp/shell/log/10018.$$ ]

then

#echo "wyk"

/opt/uniisp/shell/10018stop.sh

/opt/uniisp/shell/10018start.sh

echo "ok" >> /opt/uniisp/shell/log/10018.$$ 2>&1

fi

标的shell中的lsof之前没有写绝对路径导致一直没有输出,导致后续程序无法执行。


你可能感兴趣的:(LSOF命令在crontab中无法执行解决方法)