Skip to content

Instantly share code, notes, and snippets.

@shyamjos
Created May 11, 2019 14:02
Show Gist options
  • Save shyamjos/a553ccf8523f0d34f3e30e7230cd015f to your computer and use it in GitHub Desktop.
Save shyamjos/a553ccf8523f0d34f3e30e7230cd015f to your computer and use it in GitHub Desktop.
Systemd unit file for tcpdump with date filename
[Unit]
Description="Systemd script for tcpdump"
After=network.target network-online.target
Wants=network-online.target
[Service]
User=root
ExecStart=/bin/bash -lc 'usr/sbin/tcpdump -i eth0 -C 10000 -G 86400 -w /var/log/tcpdumps/tcp_dump_$$(date +%%Y-%%m-%%d-%%H:%%M:%%S).pcap -z gzip -s 0'
SuccessExitStatus=143
Restart=on-failure
RestartSec=10s
[Install]
WantedBy=multi-user.target
@Averell7
Copy link

Exactly what I tried (and failed !) to do. Thanks a lot
Just because I had the question, I add that -C 10000 means 10Gb, since unit of -C is 1000000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment