Working with logs in Linux

9 06 2009

linuxWhen working in Linux environment, referring log files is a very common task. Following tips may help you to perform very basic tasks with log files.

View running log
Command : # tail -f <log_file_path>
Example   : # tail -f /server/log/server.log
Comment : Dynamic log view will be the output

View the final part of the log
Command : # tail -n <num_of_lines> <log_file_path>
Example   : # tail -n 5000 /server/log/server.log
Comment : According to the example, the output will show the last 5000 lines of the log file as a static view.

View the log from start
Command : # less <log_file_path>
Example   : # less /server/log/server.log
Comment : Output will be a static log view, from the start of the log & can be navigate through using Space, Enter, Page Up, Page Down …etc keys.

View the lines which contains specific string part
Command : # cat <log_file_path> | grep <string>
Example   : # cat /server/log/server.log | grep “Failure in”
Comment : According to the example, this will display all the lines which included “Failure in” string.


Actions

Information

One response

19 06 2009
chinthaka

thanks dude,
I used $touch to update those information
(Update the access and modification times of each FILE to the current time)

Leave a comment