I am monitoring a certain port, because my application uses that port, it seems that the connection drops at random times, I want to see what are the last packets passing through before the connection drops: I used this line
sudo tcpdump -XX -i eth0 port 3050 | tail >> tcpamir.txt
but for it to work I have to start another terminal and issue
sudo killall tcpdump
is there a better approach? EDIT1: it is important to capture only the last packets since I don't want the file to balloon, since there is enough traffic to fill the disk space quickly .