Operating System - Linux
1753963 Members
7321 Online
108811 Solutions
New Discussion

tcpdump in cron runs only for 1 minute

 
Gesmundo
Advisor

tcpdump in cron runs only for 1 minute

We created an entry in cron of RHEL 6.5 to run tcpdump fro 30 minutes:

0 12 * * *  /usr/bin/nohup tcpdump -ttt -vvv -s 65535 -i bond0 -w /tmp/bond0.pcap &

30 12 * * * killall -15 tcpdump

The tcpdump runs but only for 1 minute.

We tried adding TMOUT:

0 12 * * * TMOUT=0; /usr/bin/nohup tcpdump -ttt -vvv -s 65535 -i bond0 - w /tmp/bond0.pcap &

But still runs only for 1 minute.

Any idea will be appreciated.

 

Thanks

Noel

 

1 REPLY 1
Matti_Kurkela
Honored Contributor

Re: tcpdump in cron runs only for 1 minute

When you use "nohup" that way, there should be a "nohup.out" file in the user's home directorey after running that cron job - and since tcpdump must normally be run as root, the file is probably /root/nohup.out.

What does that file say? Are there any error messages?

The -ttt and -vvv options are not necessary if you're using the -w option to write the actual dump into a file.

The TMOUT timeout applies only for interactive shells waiting for input, so it has no effect when a non-interactive session (=the one started by cron) is running tcpdump.

MK