Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I mistakenly executed the following command in the terminal:

tail -f /logs/applications/logs*

I got the following output:

tail: file shrunk!
Error 0

I am not sure what exactly happened. I have not been keeping track on the number of files in the directory for quiet a while. Could someone please explain what exactly happened, and did I lose any files.

Edit:

I am not sure if it is coincidence or not, but after I executed the code, I counted the number of files in the directory, and it was 10!

First time the number 10 got me paranoid...

share|improve this question

2 Answers 2

up vote 6 down vote accepted

I am not sure what exactly happened.

What happened was that the file was rotated by an external application. This is usual. Utilities like logrotate rotate log files, i.e. the contents of the existing log file are moved to another file and the existing one is blanked out before an application starts writing to it again.

When tail determines that the size of the tracked file has reduced, then it prints the message you observed and continues tracking the file.

Quoting from tail invocation section of GNU coreutils manual:

No matter which method you use, if the tracked file is determined to have shrunk, tail prints a message saying the file has been truncated and resumes tracking the end of the file from the newly-determined endpoint.

share|improve this answer

No you did not lose any files as tail command only shows the end of the files.

Passing /logs/applications/logs* to tail is same as passing multiple files/folders (anything that matches /logs/applications/logs* pattern). As this pattern can be matches also by directories, in these cases tail will fail to work.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.