Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
出于特定原因,我必须在函数内执行无限循环,然后将该函数作为守护进程运行,
#!/bin/sh lol(){ while true do echo "looping..." sleep 2 done } lol() &
该脚本不起作用,它给了我以下错误:
/tmp/test: line 9: syntax error: unexpected "&"
如何在函数中执行无限循环ash?
ash
您只是错误地启动了函数-与循环无关:
lol &
括号仅在函数定义时使用,不用于调用。