0

I have this cronjob that has the following two lines:

/usr/sbin/tcpdump port 8086 -i any -l -e -n | /usr/bin/perl /root/netbps.pl > /root/bw/8086.txt

/usr/sbin/tcpdump port 8085 -i any -l -e -n | /usr/bin/perl /root/netbps.pl > /root/bw/8085.txt

It passes the data to a perl script that prints bandwidth usage on these two ports and then feeds it to a timeseries db later in the script. Only the first line starts and completes as it should, the second one takes forever. It does not matter if I change their order, the second one will take nearly a minute or more, with a huge amount of packets dropped by the kernel. The first one to be executed will always run flawlessly.

The cron log shows nothing, and running the lines manually in the terminal does not change anything, and no errors are reported.

Thank you.

  • Commands are run in order, the second command doesn't run until the first one finishes. But you haven't given any options that will make the first `tcpdump` stop. – Barmar May 26 '17 at 18:47
  • How does the first one complete? – Barmar May 26 '17 at 18:48
  • The `netbps.pl` exits after 3 seconds of collecting data and with `ps ax | grep tcpdump` I see the process appearing and dissapearing as it should. But then the second appears and stays there for either very long, or as of today, until i kill the process. – GuestThatNeedsHelp May 27 '17 at 11:10
  • `tcpdump` won't exit until it gets a `SIGPIPE` due to trying to write to the closed pipe. If you don't get any traffic on the port after `netbps.pl` exits, `tcpdump` will never try to print anything and won't notice that the pipe has closed. – Barmar May 29 '17 at 21:18

0 Answers0