How To Find Error Logs In Unix
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies how to view log files in linux of this site About Us Learn more about Stack Overflow the company Business
How To View Logs In Linux Command Line
Learn more about hiring developers or posting ads with us Unix & Linux Questions Tags Users Badges Unanswered Ask Question how to check log files in putty _ Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute: Sign up Here's http://www.ibm.com/support/knowledgecenter/SSFKSJ_9.0.0/com.ibm.mq.tro.doc/q039560_.htm how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top How to grep top most frequent error messages in a unix logfile up vote 5 down vote favorite 1 If I have a file example apache log file How to extract the top most frequent error messages in a unix log file http://unix.stackexchange.com/questions/97341/how-to-grep-top-most-frequent-error-messages-in-a-unix-logfile with no timestamps the key is most frequent error message should come on top of the list linux shell grep webserver share|improve this question edited May 22 '14 at 19:18 Vldb.User 71 asked Oct 23 '13 at 5:22 Jaya William 76124 migrated from serverfault.com Oct 23 '13 at 22:04 This question came from our site for system and network administrators. 1 grep message logfile | sort | uniq -c | sort -n | head –MadHatter Oct 23 '13 at 5:45 Sorry, head should read tail. –MadHatter Oct 23 '13 at 5:58 Thanks for the edit, more clearly defining the question; Ursadon has answered it for you, so could you please accept his or her answer so we can stop this question popping up again? As you will gather by the slowly-accumulating downvotes, this question is arguably off-topic for SF. –MadHatter Oct 23 '13 at 7:27 add a comment| 2 Answers 2 active oldest votes up vote 10 down vote cat /tmp/file: ERROR 1 1234 ERROR 2 1234 ERROR 3 1234 ERROR 4 1234 ERROR 4 1234 ERROR 3 1234 ERROR 2 1234 ERROR 5 1234 ERROR
sysadmins and programmers. In this article, let us review how to effectively view and manipulate huge log files using 10 awesome examples. Example 1: Display specific lines (based on line number) of http://www.thegeekstuff.com/2009/08/10-awesome-examples-for-viewing-huge-log-files-in-unix a file using sed command View only the specific lines mentioned by line numbers. Syntax: $ sed -n -e Xp -e Yp FILENAME sed : sed command, which will print all the lines by default. -n https://www.petefreitag.com/item/426.cfm : Suppresses output. -e CMD : Command to be executed Xp: Print line number X Yp: Print line number Y FILENAME : name of the file to be processed. The example mentioned below will print the how to lines 120, 145, 1050 from the syslog. $ sed -n -e 120p -e 145p -e 1050p /var/log/syslog In the following example, you can view the content of var/log/cron from line number 101 to 110. M - Starting line number N - Ending line number Syntax: sed -n M,Np FILENAME $ sed -n 101,110p /var/log/cron Example 2: Display first N lines of a file using head command This example displays only first 15 how to check lines of /var/log/maillog file. Change 15 to 10 to display the first 10 lines of a log file. Syntax: head -n N FILENAME $ head -n 15 /var/log/maillog Example 3: Ignore last N lines of a file using head command This example shows how to ignore the last N lines, and show only the remaining lines from the top of file. The following example will display all the lines of the /var/log/secure except the last 250 lines. Syntax: head -n -N FILENAME $ head -n -250 /var/log/secure Example 4: Display last N lines of the file using tail command This example displays only last 50 lines of /var/log/messages file. Change 50 to 100 to display the last 100 lines of the log file. Syntax: tail -n N FILENAME $ tail -n 50 /var/log/messages Example 5: Ignore first N-1 lines of the file using tail command This example shows how to ignore the first N-1 lines and show only the remaining of the lines. The following example ignores the 1st four lines of the /etc/xinetd.conf, which contains only the comments. Syntax: tail -n +N FILENAME $ tail -n +5 /etc/xinetd.conf defaults { instances = 60 log_type = SYSLOG authpriv log_on_success = HOST PID log_on_failure = HOST cps = 25 30 } includedir /etc/xinetd.d Example 6: Vie
need to know a few of them. I use unix quite a bit, usually either on one of our Linux servers, or on my Powerbook with OS X. And these are the 15 commands that I use most. If you can memorize these 15 commands, you can do quite a bit on a unix operating system, and add unix as a skill on your resume. The 15 Most Important UNIX commands man - show manual for a command, example: man ls hit q to exit the man page. cd - change directory, example: cd /etc/ ls - list directory, similar to dir on windows. example: ls /etc, use ls -l /etc to see more detail cp - copy a file or directory, example: cp source dest if you want to copy a directory use the -R option for recursive: cp -R /source /dest mv - move a file, example: mv source dest rm - remove a file, example: rm somefile to remove a directory you may need the -R option, you can also use the -f option which tells it not to confirm each file: rm -Rf /dir cat - concatenate, or output a file cat /var/log/messages more - outputs one page of a file and pauses. example: more /var/log/messages press q to exit before getting to the bottom. You can also pipe to more | more from other commands, for example ls -l /etc | more scp - secure copy, copies a file over SSH to another server. example: scp /local/file user@host.com:/path/to/save/file tar - tape archiver, tar takes a bunch of files, and munges them into one .tar file, the files are often compressed with the gzip algorithm, and use the .tar.gz extension. to create a tar tar -cf archive.tar /directory, then to extract the archive to the current directory run tar -xf archive.tar to use gzip, just add a z to the options, to create a tar.gz: tar -czf archive.tar.gz /dir to extract it tar -xzf archive.tar.gz grep - pattern matcher, grep takes a regular expression, or to match a simple string you can use fast grep,