S
S
silvanesti2018-09-26 08:59:08
linux
silvanesti, 2018-09-26 08:59:08

How to save the values ​​from the log for the last two days?

There is an ipfw log, here is its format:
Sep 26 07:49:23 freebsd2 kernel: ipfw: 45 Deny TCP 185.234.219.29:58871 8.8.8.8:25 in via stge0
That is, you have to take into account the month and day (time is not important).
Construction like:
grep "$(date -v-2d +"%b %d")" $ipfw/ipfw.log >> $ipfw/reject_log_2d extracts
messages that happened two days ago, but it should be for the last two days - how to do it ?
You can, of course, pull out several times for different dates and mold into one, but I would like to know how this can be done with one command.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Ermilichev, 2018-09-26
@silvanesti

grep "$(date -d "-2day" +"%b %d")\|$(date -d "-1day" +"%b %d")\|$(date -d +"%b %d")"  $ipfw/ipfw.log >> $ipfw/reject_log_2d

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question