Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    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?

  2. #2
    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.:

    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:

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

    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