1
所以我while循环工作正常,但是当我添加了timeout命令它给我这个错误:错误添加超时命令时,while循环在bash
bash: syntax error near unexpected token `do'
下面是一个命令:
timeout 30s while [ $? = 0 ]; do kill -0 $MYPID 2>/dev/null; if [ $? = 0 ]; then echo The Process PID is running && date +%r; else echo the Process PID is NOT running && date +%r; fi; done
你执行命令'timeout'带参数的'30s','while','[','$','? =','0'和']'。然后你想执行'do ...'。当bash分析你的线路时,它会抱怨这个“do”在这里没有合法的结构......这是意想不到的! – 2014-10-30 23:06:12
你可以像这样包装所有东西:'timeout 30s bash -c'while ....''。 – 2014-10-30 23:08:27
非常感谢!这解决了它。 – the1osu 2014-10-30 23:12:11