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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with script, trying to get tcpdump and rotate the file every 300 seconds
# 1  
Old 11-22-2006
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
# 2  
Old 11-22-2006
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 ........
# 3  
Old 11-22-2006
yes, i wanted to test it out and i left it for 2 seconds... any ideas on how to achieve this?
# 4  
Old 09-10-2008
Try this

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

more info is at the man page

Manpage of TCPDUMP
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to move .300 extension file from 1 dir to other and email

Hi, I am looking for a shell script which move .300 extension files from /home/sofia/ to /home/sofia/test and sends me an email with the list of files moved like this :- The following files has been moved from /home/sofia/ to /home/sofia/test 1. alpha.300 2. beta.300 Email only if the... (4 Replies)
Discussion started by: sofia8679
4 Replies

2. UNIX for Dummies Questions & Answers

Need script to rotate logs

I have few solaris-10 non global zones, where one application is writing some logs to /var/ovd/ConfigLogs. It keeps increasing all the time, as it is needed by application team as of now. I want a small script, which I can configure in cronjob, which should : - Run every Saturday 10 PM - Copy... (5 Replies)
Discussion started by: solaris_1977
5 Replies

3. HP-UX

How To Rotate A File in HP-UX?

I need to rotate a file in HP-UX of a application. I´ve tried to do a task in the cron with a script (with sed and ed commands) but it was a successfully option (the application continued writing the file :( ) LINEAS_OUT=$(wc -l < $RMISTDOUT) LINEAS_FIN=1,expr $LINEAS_OUT - 100p sed... (19 Replies)
Discussion started by: werkraft
19 Replies

4. Shell Programming and Scripting

Script to rotate file log

Hi Experts, I have script on crontab and give output quite large. I would like to know how to create rotate log when the size of log maximum 50MB if the test.log is 50MB then create test.0 Thanks Edy (2 Replies)
Discussion started by: edydsuranta
2 Replies

5. Shell Programming and Scripting

Help with a rotate log script

Hi all, Am trying to write my own log rotate script. Curremtly, what I have is as below: #!/bin/ksh file_to_rotate=${1} x=${2} while ] do let curr=${x} let prev=${x}-1 if ] ; then #echo "cp -p ${file_to_rotate} ${file_to_rotate}.${curr}" cp -p... (7 Replies)
Discussion started by: newbie_01
7 Replies

6. Shell Programming and Scripting

cron script to rotate log files

I have a mac server. I have been having problems with my logs. My hard disk became full, when i researched into why it was full it was due to massive log files. There was barley any log rotation policies in place on the server. I tired to use logrotate. This doesn't work on my server. It is a MAC... (19 Replies)
Discussion started by: timgolding
19 Replies

7. Shell Programming and Scripting

Script for Log Rotate

Hello, I only know the basic for shell programing. I need help for this, I thinks this is a basic for anyone who know a litle of shell scripting. I need creat a script for a rotatate logs, when a filesystem is full. I have a filesystem. The rotate consist in zip the current log (copy) and... (1 Reply)
Discussion started by: El Rengo
1 Replies

8. Shell Programming and Scripting

Perl script to rotate logs

I have a shell script that will gzip/tar/archive application logs that are over 20 days old which works just fine, but I would like to convert to a Perl script. Problem is, I'm a beginner with Perl and all attempts so far have failed. Basicaly I have a log dir /app/logs that contains several... (18 Replies)
Discussion started by: theninja
18 Replies
Login or Register to Ask a Question