How to schedule tcpdump to run for a specific period of time?

前端 未结 5 948
我寻月下人不归
我寻月下人不归 2021-01-30 16:28

Each time, when I manually run tcpdump, I have to use Ctrl+C to stop it. Now I want to schedule my tcpdump with cronjob and I onl

5条回答
  •  粉色の甜心
    2021-01-30 17:28

    The approach that worked best for me on Ubuntu 14.04

    sudo -i
    crontab -e
    

    and then add the line

    30 17 * * * /usr/sbin/tcpdump -G 12600 -W 1 -s 3000 -w /home/ubuntu/capture-file.pcap port 5060 or portrange 10000-35000
    

    Notes

    • -G flag indicate number of second for dump to run, this example runs daily from 5:30 PM to 9:00 PM
    • -W is the number of iterations tcpdump will execute
    • Cron job will not be added until you save and exit the file
    • This example is for capturing packets of an Asterisk phone server

提交回复
热议问题