Как запустить tcpdump на определенный интервал времени

You can combine -G {sec} (rotate dump files every x seconds) and -W {count} (limit # of dump files) to get what you want:


tcpdump -G 15 -W 1 -w myfile -i eth0 'port 8080'

would run for 15 seconds and then stop. Turn 1.5 hours into seconds and it should work.

Or you could use timeout:


timeout 5400 tcpdump -i eth0 'port 8080' -w myfile

You could do it like this:


tcpdump -i eth0 'port 8080' -w  myfile & 
pid=$!
sleep 1.5h
kill $pid

Pruflink