我有一个bash脚本,其中我执行一行,休眠一段时间,然后在tail -f
日志文件中验证是否可以看到某种模式,按ctrl + c退出,tail -f
然后移至下一行直到bash脚本完成执行:
到目前为止,这是我所做的:
#!/bin/bash
# capture the hostname
host_name=`hostname -f`
# method that runs tail -f on log_file.log and looks for pattern and passes control to next line on 'ctrl+c'
echo "==================================================="
echo "On $host_name: running some command"
some command here
echo "On $host_name: sleeping for 5s"
sleep 5
# Look for: "pattern" in log_file.log
# trap 'continue' SIGINT
trap 'continue' SIGINT
echo "On $host_name: post update looking for pattern"
tail -f /var/log/hadoop/datanode.log | egrep -i -e "receiving.*src.*dest.*"
# some more sanity check
echo "On $host_name: checking uptime on process, tasktracker and hbase-regionserver processes...."
sudo supervisorctl status process
# in the end, enable the balancer
# echo balance_switch true | hbase shell
该脚本有效,但是我得到了错误,需要更改什么/我在做什么错?
./script.sh: line 1: continue: only meaningful in a `for', `while', or `until' loop
也可能与此页面的访问者相关:unix.stackexchange.com/questions/163561/…–
—
pestophagous