Archive for March, 2012

Following files using tail

Saturday, March 3rd, 2012 | Life, Tech

Tail is a useful command which allows you to see the end of a file. This is probably most commonly used when you want to look at log files as the entries of most interest are usually at the bottom. For example, if you wanted to view the last 50 lines of a log file you could use the following command.

tail -n 50 filename.log

A cool feature of tail is that you can also follow a file – that means continually monitoring it as changes come in. So if you are looking at the Apache error log for example, you could begin tailing the log and then cause an error and you will see it instantly come through on the log.

tail -f error_log