Which command will efficiently allow a monitoring script to display the last five entries of a log file and continue to output any new entries as they are appended, while also ensuring that file rotations are handled correctly by tracking the file descriptor?
The command tail -F -n 5 /var/log/webserver.log addresses the question's requirements by using -F (capital F), which not only outputs the last five lines of the file with -n 5 but also monitors the file descriptor in case the log file is rotated, as is common with log management. This is useful for system administrators who want to ensure that the monitoring script continues to function even if the original log file is archived and a new one is created. The wrong answers either don't follow the file descriptor changes (tail -f -n 5), don't provide real-time monitoring (tail -n 5), or lack specificity in tracking the correct number of lines (tail -F).
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
What does the '-F' option do in the 'tail' command?
Open an interactive chat with Bash
How does log file rotation work, and why is it important?
Open an interactive chat with Bash
What is the difference between '-f' and '-F' in the 'tail' command?