When redirecting tail -F output fail after log rotation?

Redirecting the tail output fails when log rotation happens even though i have used -F. But when i tail and see the output on terminal this does not happen. Note i have also used & to execute this statement in background.

Suppose if i want to tail a file /opt/SAMPLE.txt and redirect its output to /var/tmp/capturelog/SAMPLE.txt, the below code is working fine if i call the method tailf() as tailf /opt/SAMPLE.txt it works fine until /opt/SAMPLE>txt file is rotated.

once the file /opt/SAMPLE.txt got rotated my output redirection stops to /var/tmp/capturelog/SAMPLE.txt

tailf() {
filename=$(basename $1)
tail -F -n 0  $1 >/var/tmp/capturelog/$filename &
}

Did you consider trying the

option to tail?