This quick article is more for me to have a safe place to jot down this command so I don’t need to re-research it every time.

I want to take a packet capture with tcpdump on a server and have the file rotate every hour.

Command:

tcpdump icmp -G 3600 -W 8 -w icmp-%Y-%M-%d_%H.%M.%S.pcap

Let’s break it down.

tcpdumpThe command we are executing to capture packets
icmpIn this example i’d only like to capture ICMP traffic
-G 3600I’d like the file to rotate every 3600 seconds (1 hour)
-W 8I’d like the application to only hold a max of 8 files
-w filenameThe output file. In my example I have put placeholders that will print the date in the file capture