Find the answer to your Linux question:
Results 1 to 2 of 2
I have a script where I want to run tcpdump and then immediately run another command however, tcpdump will cause the shell pause/hang so the following command lines will have ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    May 2012
    Posts
    85

    how to run tcpdump on background?


    I have a script where I want to run tcpdump and then immediately run another command
    however, tcpdump will cause the shell pause/hang
    so the following command lines will have no chance to run

    even if I use &, it doesn't help
    are there any solutions?
    thanks

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,307
    use GNU screen, i'd say. it is a terminal emulator that allows you to create a virtual terminal that you can run bash scripts and commands in and throw it in the background, great for stuff like this, e.g.:

    Code:
    screen -S "TCPDump" -dm tcpdump -i wlan0
    this will start a screen named "TCPDump" and run it in the background (-dm) and the command passed to it will be "tcpdump -i wlan0".

    you can see running screen sessions with:

    Code:
    screen -ls
    and then reattach to the pid or the name of a session (listed in the "screen -ls" command) with, e.g.:

    Code:
    screen -r TCPDump
    check out the man page ("man screen") to learn the many options available in screen.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •