LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking > Linux - Wireless Networking
User Name
Password
Linux - Wireless Networking This forum is for the discussion of wireless networking in Linux.

Notices


Reply
  Search this Thread
Old 05-17-2012, 04:18 AM   #1
omega341991
Member
 
Registered: May 2012
Posts: 39

Rep: Reputation: Disabled
how to limit the tcpdump command to a time interval


i would like to know how to limit the duration of packet capture using tcpdump. For Eg.capturing data for 10 seconds using tcpdump
 
Old 05-17-2012, 05:35 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,852

Rep: Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311Reputation: 7311
it looks you need to use another tool and stop tcpdump.
there is a coreutils package and it contains a timeout command.
http://www.gnu.org/software/coreutils/
http://www.gnu.org/software/coreutil...out-invocation
 
Old 05-17-2012, 05:51 AM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
For systems w/o 'timeout', and unless you know what traffic rate you have (check 'man tcpdump' for capture size), here's another easy way:
Code:
/path/to/tcpdumpbinary --whatever-args-you-need &
sleep 10s && pkill -HUP -f /path/to/tcpdumpbinary
* If you aim for longer capture durations there's also the 'at' service:
Code:
echo "/path/to/tcpdumpbinary --whatever-args-you-need"|/usr/bin/at now
echo "pkill -HUP -f /path/to/tcpdumpbinary"|/usr/bin/at now +30 minutes
 
Old 05-17-2012, 05:59 AM   #4
omega341991
Member
 
Registered: May 2012
Posts: 39

Original Poster
Rep: Reputation: Disabled
thanks a lot pan64
its works like a charm
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
extract from nginx log time interval mad_penguin Linux - Newbie 2 02-02-2012 11:35 PM
ISPConfig and Command time limit exceeded error on mail Pooh Linux - Server 3 01-07-2010 01:35 AM
How to perform command in time interval? your_shadow03 Linux - Newbie 2 06-16-2009 01:11 AM
Change my mac address in interval of time!! wanas Linux - Networking 8 03-27-2009 03:10 AM
Give a command a time limit to exit/complete ? FormalLogic Linux - General 1 03-27-2008 02:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking > Linux - Wireless Networking

All times are GMT -5. The time now is 09:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration