Question
A systems administrator wants to review the logs from an Apache 2 error.log file in real time and save the information to another file for later review. Which of the following commands should the administrator use?
- A. tail -f /var/log/apache2/error.log > logfile.txt
- B. tail -f /var/log/apache2/error.log | logfile.txt
- C. tail -f /var/log/apache2/error.log >> logfile.txt
- D. tail -f /var/log/apache2/error.log | tee logfile.txt Correct
Explanation
tail -f follows the log as new lines arrive, and piping it into tee copies standard input both to the screen and to logfile.txt, so the administrator watches the log live and keeps a copy. The > and >> redirections send the output only to the file, so nothing appears on the screen in real time. Piping into logfile.txt is invalid because a pipe needs a command, not a file name.