sushil sinha
sushil sinha

Reputation: 71

Quit tail -f command from script

I am doing tail -f -n 10 test.log .

I want this tail command to terminate once a signal file is created at some location .

say finish.txt. If finish.txt file exists then stop tailing or else continue

Upvotes: 1

Views: 96

Answers (1)

Fravadona
Fravadona

Reputation: 17216

That should take care of the problem:

signal_file=some/location/finish.txt

tail -f -n 10 test.log &

until [ -e "$signal_file" ]; do sleep 1; done

kill %

Upvotes: 2

Related Questions