I'm looking to be able to capture a rotating tcpdump output which captures 30 minutes worth of data, into 48 files, cyclically.
The man page implies this should be possible, but my testing doesn't seem to produce the result I'm looking for:
-W
Used in conjunction with the
-C
option, this will limit the
number of files created to the specified number, and begin
overwriting files from the beginning, thus creating a 'rotating' buffer.
In addition, it will name the files with enough
leading 0s to support the maximum number of files, allowing
them to sort correctly.Used in conjunction with the
-G
option, this will limit the
number of rotated dump files that get created, exiting with
status 0 when reaching the limit. If used with-C
as well, the
behavior will result in cyclical files per timeslice.
I'm running this on OS X 10.9.5/10.10.3 clients. Here's the test command; it just exits after the 3rd file:
tcpdump -i en0 -w /var/tmp/trace-%Y-%M-%d_%H.%M.%S.pcap -W 3 -G 3 -C -K -n
Best Answer
That's because you wrote
-W 3
instead of-W 48
. There are, however, other errors in your command.The option
-G
means:Since you wrote
-G 3
, you will be rotating this every 3 seconds, while you statedAlso, the naming scheme is wrong: from the above,
Thus there is no point in specifying the time format for the name.
Further, the
-C
option has no argument, while, according to the man page, it should:The man page states:
So you should specify
-C 100
in order to produce 100 MB files.In the end, your command should be:
This will rotate files (of names trace1, trace2, ...) cyclically, with period 48, either every 1800 seconds (=30 minutes) or every 100 MB, whichever comes first.