SoFunction
Updated on 2025-03-10

Use the vi command to delete all contents in the log and monitor the log in real time

Many times, we need to check log files for troubleshooting applications. However, there are usually many logs generated by our previous applications. When there are too many other logs, it sometimes seems a bit difficult to look at the logs generated by the current application. At this time, we may want to clear the previous logs to make the logs generated by the current application look clear:

vi 

:0,$d
:wq

Comments: :0,$d means to delete the 0th line to the last line; :wq means to save and exit.
Then enter the following command to monitor the contents in real time:

tail -f 

Note: The tail command is to view the last 10 lines of the file, and the -f parameter means that the view changes as the file increases.