Cannot use tail -f to monitor log file
I use tail -f on /var/log/messages to check the latest update on the log file. It show last 10 line of the file and
command continue to run but didn't show the update of the log file (real time). As I know , the command should show latest entry to the log file time to time I use this "tail -f /var/log/messages" pls anyone guide me what did i do wrong. |
I am not sure you are doing anything wrong....have you checked that there were changes?
I had to use /log/auth.log and open and close a root terminal to prove it works ok for me tail -f /var/log/auth.log |
Quote:
Can you tell me why ? I create a file with touch "touch test "and tried to change the file during the monitoring period (tail -f touch )but tail -f shows nothing . Please explain me thank you for your help |
tail -f is not showing anything because the file is empty and not changing
Code:
c:/tmp$ touch foo |
Quote:
Sorry I forgot to mention that After "touch" I "vim touch test" and add some line but In the mean time I run tail -f from the beginning but shows nothing . |
You created a new file which tail is not monitoring. Instead open two terminals in the same directory. run:
touch testfile tail -f testfile Now in the second terminal, run "ls >>testfile. When a program opens a file, it gets a file descriptor back, which is an integer. This file descriptor is used for further reads and writes. When you saved the file you loaded in vim, you created a new file with a new inode. The tail command still has the original file open. It won't be closed until you quit "tail -f" by pressing CTRL-C. After doing that, the kernel will delete the file. Code:
touch testfile2 |
Quote:
Code:
c:/tmp$ rm foo |
Quote:
thank you |
All times are GMT -5. The time now is 03:20 AM. |