This tutorial is meant for those who are newbies to the Linux environment and please feel free to add any suggestion to this material. The command tail is used to output the last part of a file (e.g tail mylog.txt ) this will output the last 10 lines of mylog.txt by default , you can change this by adding an extra parameter to your tail command (e.g tail -n 100 mylog.txt) this will now return the last 100 lines from mylog.txt as suppose to the default 10 lines.
My favorite parameter which you can use with tail command allows you to monitor log files as they are being populated (e.g tail -f mylog.txt) first it will show me the default 10 lines but then as soon as a new entry is inserted into the mylog.txt I will be able to see it without reloading the file or the command, This is useful if you are debugging anything that writes to a log file because you can monitor the log while you attempting to fix your problem.
So next time you want to monitor your log files try and use tail to capture your errors and please try not use vi on log files which are very big(e.g A 5 gigabyte log file will crash your server if you do a vi on it,unless you have a very very very big server thats never worries about Ram ) But you can always tail a big log file and if that does not help then you can try using grep which is something else all together.
Tags: linux, tail
Recent Comments