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

LA_*_*LA_ 1 bash ubuntu nohup

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

while true; do timeout 1h python worker.py --log-level=ERROR; done
Run Code Online (Sandbox Code Playgroud)

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

nohup while true; do timeout 1h python worker.py --log-level=ERROR; done &
Run Code Online (Sandbox Code Playgroud)

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

什么是正确的语法?

小智 6

尝试

nohup bash -c 'while true; do timeout 1h python worker.py --log-level=ERROR; done'
Run Code Online (Sandbox Code Playgroud)