Utility to grep log between two dates or tail last lines to time ago similar dategrep or dateutils.
Grep last minute from current nginx access log (binary search):
$ timegrep --format=nginx --minutes=1 /var/log/nginx/access.log
Grep datetime interval from archive log (sequential read data from stdin
):
$ zcat archive.log.gz | timegrep --start='2017:09:01 15:23:00' --stop='2017:09:01 16:32:00'
- Precompiled static binaries built with system libc (glibc) and musl libc for x64 and i386
- From source code:
$ git clone https://github.com/abbat/timegrep.git
$ make && sudo make install
To compile with own flags use USER_CFLAGS
and USER_LDFLAGS
variables. For example for i386 static binary with musl libc:
$ CC=musl-gcc32 USER_CFLAGS=-m32 USER_LDFLAGS='-L/usr/lib/i386-linux-gnu -m32 -static -Wl,-melf_i386' make
timegrep [options] [files]
Options
--help
,-?
- print help message and named datetime formats;--version
,-v
- print program version and exit;--format
,-e
- datetime format (default: 'default');--start
,-f
- datetime to start search (default: now);--stop
,-t
- datetime to stop search (default: now);--seconds
,-s
- seconds to substract from--start
(default: 0);--minutes
,-m
- minutes to substract from--start
(default: 0);--hours
,-h
- hours to substract from--start
(default: 0).
See strptime(3) for format details. See --help
for list of format aliases.
0
- successful completion;1
- nothing found;2
- general application error.
- Translate this document or man page to your native language;
- Proofreading README.md or man page with your native language;
- Share, Like, RT to your friends;
- Send PRs if you are developer.