Use shell commands to analyze statistics logs
When you need to collect user log information and analyze user behavior, you can use shell to conveniently retrieve a lot of data and place it in excel for statistics.
For example, for access with the address loadCustomProcess included in the statistics log, sort by access time consumption:
Grep "loadCustomProcess"/home/workflow/socket.txt | awk-F "" '{print $11}' | awk-F ": "'{print $2}' | sort-nr
When "INFO" is displayed, the first 10 records are displayed:
Grep "INFO"/usr/share/tomcat6/logs/flowplatform. log | awk-F "'{print $8}' | sort | uniq-c | sort-nr
Resolution:
Grep "loadCustomProcess"/home/workflow/socket.txt find the row containing loadCustomProcess in the file/home/workflow/socket.txt.
Uniq-c: calculates the number of consecutive occurrences (note that this is continuous). Therefore, before uniq-c, you must use sort to obtain the count effect in SQL.
For the SELECT field in an awk SQL statement, "-F" "indicates that each row of data is separated by space. Each unit is a field, and" $7 "indicates the seventh field.
Sort the results to prepare for the subsequent summary,
Sort-nr is arranged in descending ORDER of numerical values, which is equivalent to order by... DESC in SQL,
Head-10: Top 10