Posts

Showing posts from October, 2009

Easy way to extract Logs on a Date/Line Range in LINUX

Example: range of date to be extracted in the /var/log/message. Oct 26-27 our x will be Oct 26, y will be Oct 27 1. Get the first line number which will be our x reference (x - Oct 26). $ grep -n 'Oct 26' /var/log/messages | head The initial reference of x = 29933 Sample Output: 29933:Oct 26 00:00:00 postfix nagios: LOG ROTATION: DAILY 29934:Oct 26 00:00:00 postfix nagios: LOG VERSION: 2.0 29935:Oct 26 00:00:00 postfix nagios: CURRENT HOST STATE: localhost;UP;HARD;1;PING OK - Packet loss = 0% 29936:Oct 26 00:00:00 postfix nagios: CURRENT SERVICE STATE: localhost;Current Load;OK;HARD;1;OK 29937:Oct 26 00:00:00 postfix nagios: CURRENT SERVICE STATE: localhost;Current Users;OK;HARD;1 29938:Oct 26 00:00:00 postfix nagios: CURRENT SERVICE STATE: localhost;HTTP;WARNING 29939:Oct 26 00:00:00 postfix nagios: CURRENT SERVICE STATE: localhost;PING;OK;HARD;1;PING OK - Packet loss = 0% 29940:Oct 26 00:00:00 postfix nagios: CURRENT SERVICE STATE: localhost;Root