原帖由 ballatong 于 2009-2-23 11:11 发表
按照楼上前辈的方法
cat -A detect.sh
后发现文件末行后多了^M$ 我猜是多了回车
去掉后就好了
#! /bin/sh
FILESRV= ping -c1 10.198.112.18 |grep 10.198.112.18 |grep -c ttl
FILESRV_status=`grep -c ...
原帖由 ballatong 于 2009-2-23 11:11 发表
按照楼上前辈的方法
cat -A detect.sh
后发现文件末行后多了^M$ 我猜是多了回车
去掉后就好了
#! /bin/sh
FILESRV= ping -c1 10.198.112.18 |grep 10.198.112.18 |grep -c ttl
FILESRV_status=`grep -c ...
原帖由 ballatong 于 2009-2-23 11:32 发表
在if 前插入
echo $FILESRV
结果
0
detect2.sh: line 5: [: FILESRV: integer expression expected
$FILESRV的结果是对的,因为那个ip是不同的,需要返回0
我是DBA (我在学习,我要进步) |
原帖由 ballatong 于 2009-2-23 16:57 发表
谢谢大家,这个shell终于可以运行了
现在问题是如何把它放到crontab中 每5分钟一次
我是用
crontab -e
加入
*/5 * * * * root /pub/detect.sh
但好像不起作用
FILESRV= ping -c1 10.198.12.18 |grep 10.198.12.18 |grep -c ttl
欢迎光临 Chinaunix (http://bbs.chinaunix.net/) | Powered by Discuz! X3.2 |