- 论坛徽章:
- 0
|
写了一个自动抓日志的脚本,想在发现某机器有问题时,从中控机远程执行该脚本,脚本执行完毕后,会用sz命令将日志发到我本机上面。代码如下:
while [ $? -eq 0 ]
do
sleep 500
NUM=`ps aux | grep delldset* |grep -v grep |wc -l`
while [ $NUM -gt 0 ]
do
sleep 5
NUM=`ps aux | grep delldset* | grep -v grep | wc -l`
# continue
done
dsetfile=`ls -t /root/DSET* | head -1`
smartdev=`cat /var/log/messages | grep -i 'i\/o\ error' | cut -d',' -f 2 | awk '{print $2}'`
if [ -z "$smaratdev" ];then
smartdev=`cat /var/log/messages | grep -i 'filesystem' | cut -d'"' -f2`
fi
smartcmd=`smartctl -ai /dev/$smartdev > /tmp/smart.txt`
smartfile=/tmp/smart.txt
unix2dos /tmp/smart.txt
[ -f /usr/bin/sz ] || yum install lrzsz -y
/usr/bin/sz -yqb $dsetfile $smartfile
exit 0
done
但是实际测试中,如果该脚本直接在有问题的机器上面执行,则运行正常,可以将日志发到我本机上面;但是如果我在中控机上面远程执行则不能发到我的机器上面,试着将这个脚本用screen运行,在执行sz -yqb $dsetfile时就报错了。
[root] DSET_Report_for_[localhost.localdomain-SvcTag-D3S9V2X-PER710]-on-10-01-2011-at-10-35-AM.zip/ZMODEM: getnak faile
[root] ZMODEM/DSET_Report_for_[localhost.localdomain-SvcTag-D3S9V2X-PER710]-on-10-01-2011-at-10-35-AM.zip: error occured
这个问题如何解决,望高手指教。 |
|