I need to get output of any lines in all Apache access log files that have 25/Jan/2013:00:25 in them. My hosting company are being unhelpful in my investigation to track down what domain is allowing a spammer to send out mail

I wanted to just search a "global" log file for all access through Apache regardless of the domain but have been told there isn't such a thing and I must search all log files for all domains separately

The path wildcard(s) is/are /var/www/vhosts//statistics/logs/access_log and /var/www/vhosts//statistics/logs/access_log.processed

Is there a grep command I can run to get all matching lines from all files?


Sure, grep can work with multiple files. Just run

grep '25/Jan/2013:00:25' /var/www/vhosts/*/statistics/logs/access_log{,.processed}

Your shell should do the expansion without problem, if you want more details about shell expansion have a look here:

BTW, double check your time string.

  • Do you mean it seems wrong because there aren't any seconds on the time? I left seconds out because I want to return lines between 00:25:00 and 00:25:59, would this work like that? – Andy Jan 25 '13 at 15:07
  • @Andy: Yes. I am just not sure about the colon after the year. – choroba Jan 25 '13 at 15:09
  • Just omit the last two character in your search string :) – Shadok Jan 25 '13 at 15:09
  • @choroba I'm not sure why but after looking at one log the format is definitely like that – Andy Jan 25 '13 at 15:10
  • @Andy: OK. I just was not sure. – choroba Jan 25 '13 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.