我需要从终端重复(每 3600 秒)运行以下命令:
if whois abcxyz.com | grep -q 'string'; then
echo 'Message line 1'
echo 'Message line 2'
fi
我尝试使用手表,如下所示:
watch -n 3600 if whois abcxyz.com | grep -q 'string'; then
echo 'Message line 1'
echo 'Message line 2'
fi
但我收到错误消息。
你能帮我让它工作吗?
谢谢
由于默认watch [options] command
执行command
using sh -c
,您可以直接使用它运行 shell 代码片段,前提是:
和
所以例如
$ watch -n 36 'if whois abcxyz.com | grep -q "string"; then
echo "Message line 1" | ts
echo "Message line 2" | ts
fi'
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句