Help with script, trying to get tcpdump and rotate the file every 300 seconds

Greetings, I just started using scripting languages,
im trying to get a tcpdump in a file, change the
file name every 5mins ... this is what i have but its
not working ... any suggestions?

#!/bin/bash
# timeout.sh

#timestamp format
TIMESTAMP=`date -u "+%Y%m%dT%H%M%S"`

#tdump =`tcpdump -w dump.out -s 1514`
#tcpdump -w dump.out -s 1514 &

while sleep 2
do
echo starting tcpdump
#tcpdump -w dump.out -s 1514
tcpdump -s 5060 > dump.out
mv dump.out dump.out_${TIMESTAMP}
echo file output is dump.out_${TIMESTAMP}
done

I have two questions .

  1. What is the error you are getting ?.
  2. From your code i understand that it sleeps for 2 seconds and takes a tcpdump. But your requirement is for 5 minutes. Your script changes names for every two seconds.
    Sleep takes seconds as its arugment.

Let me know if this helps ........

yes, i wanted to test it out and i left it for 2 seconds... any ideas on how to achieve this?

Try this

tcpdump -G 300
that will rotate the file every 5 minutes

more info is at the man page

Manpage of TCPDUMP