0

In case there's a better solution to the problem, my goal is to be able to quickly analyze ALL recent apache activity in /usr/local/apache/domlogs. The usefulness of this is when the server load is going through the roof I want to quickly see which website(s) are getting hammered (and what URLs) without having to individually grep/awk everything in domlogs.

For example, I know I can get a list of the very recently active apache access domlogs using this command within the domlogs directory:

find -regex '.*\.\(com\|org\|net\|biz\|info\)' -mmin -1

Now what I'd like to do is concatenate the tail 1000 lines of each of those files into a new file so I can quickly analyze it and see where all the traffic is coming from.

1 Answer 1

1

You can use -exec option:

find -regex '.*.(com\|org\|net\|biz\|info)' -mmin -1 \
    -exec tail -n 1000 "{}" >> logs.txt +

Now all last 1000 lines of each files in domlogs is written to file logs.txt, separated by filename.

-exec command {} + tells find to run command with files found, the command line is built by appending each filename at the end. This option works line combination of find pipe to xargs.

See more:

2
  • Superb, works great. Is there any way to suppress the headers that are automatically inserted into logs.txt, e.g. ==> ./mydomainname.com <== Commented Jul 28, 2014 at 21:20
  • @CantonBecker: I think no way, maybe you have to do it yourself.
    – cuonglm
    Commented Jul 29, 2014 at 1:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .