如何在nohup中使用`while true`?

时间:2016-08-27 11:06:51

标签: bash ubuntu nohup

我想在远程Ubuntu PC(AWS)上运行脚本。

while true; do timeout 1h python worker.py --log-level=ERROR; done

效果很好,但是当我添加nohup时:

nohup while true; do timeout 1h python worker.py --log-level=ERROR; done &

它返回错误-bash: syntax error near unexpected token 'do'

什么是正确的语法?

1 个答案:

答案 0 :(得分:6)

尝试

nohup bash -c 'while true; do timeout 1h python worker.py --log-level=ERROR; done'