Answers differ based on context. To quit tail -f elegantly, you will need a trigger. Assume you are trying to monitor output of a task that will finish at some point in time - that can become your trigger. task >& filename.log & task_pid=$! tail -f filename.log & tail_pid=$! while [ 1 ] do # -0 is a special "poke" signal - "are you around?" More @Wikipedia
Hover over any link to get a description of the article. Please note that search keywords are sometimes hidden within the full article and don't appear in the description or title.