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 &
括弧は関数の定義時にのみ使用され、呼び出しには使用されません。