Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8864891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T16:22:01+00:00 2026-06-14T16:22:01+00:00

I have a bash script like this: #!/bin/bash while true; do sudo tcpdump -i

  • 0

I have a bash script like this:

#!/bin/bash
while true; do
    sudo tcpdump -i eth0 -w dump.pcap -c 1500 &
    chromium-browser --app http://domain.com &
    sleep 60
    killall chromium-browser
    sudo killall tcpdump

    # do some stuff with pcap file
    # it basically converts the pcap to plain text using tshark
    # then a PHP script parses the plain text

    sleep 240
done

It works fine. But sometimes, for whatever reason, nothing is killed and the script gets stuck in that loop step. It is actually doing nothing, not taking any resource. It seems like the script is waiting for something to be killed.

I’ve tried limiting the packets captured by tcpdump, but it didn’t work. tcpdump finishes its job normally, without having to be killed, but the script doesn’t kill chromium and it doesn’t proceed with the rest of the code.

Is there any way to detect if a step is taking too long and simply kill everything and move to the next step?

Update

The it is a long code

It converts the pcap file to plain text using tshark and a PHP script parses the plain text. The problem is not on this part because tshark is never called nor the PHP script. Everything stops before that.

Increasing the sleep

It does not reproduce the problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T16:22:02+00:00Added an answer on June 14, 2026 at 4:22 pm

    If you don’t mind processes exiting non-gracefully you could use SIGKILL instead of SIGHUP:

    killall -9 chromium-browser
    sudo killall tcpdump
    

    However in this case it is preferable to capture the pids of the processes you have started and only kill those (instead of killing all chromium-browers and tcpdump instances).

    You can access the pid of the last run process with $!.

    sudo tcpdump -i eth0 -w dump.pcap -c 1500 &
    tcpdump_pid=$!
    chromium-browser --app http://domain.com &
    chromium-browser_pid=$!
    sleep 60
    kill -9 $tcpdump_pid
    sudo kill $chromium-browser_pid
    

    To answer your question of “Is there any way to detect if a step is taking too long and simply kill everything and move to the next step?” I would suggest using the timeout utility in coreutils.

    timeout 5 sudo kill -9 $chromium-browser_pid
    

    Although it would be advisable to determine why this is hanging, rather than work around it, else you will have a resource leak. It face it will be neater to rewrite your loop in terms of timeout:

    sudo timeout 60 tcpdump -i eth0 -w dump.pcap -c 1500 &
    timeout 60 chromium-browser --app http://domain.com &
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bash script like this: #!/bin/bash startsomeservice & echo $! > service.pid
I have a bash script that looks like this: #!/bin/sh previousRelease=`git describe --tags --match
I have a script that looks like this #!/bin/bash function something() { echo hello
I have a bash script, that I run like this via the command line:
I have a bash script mystuff containing a line like lynx -dump http://example.com >tmpfile
I have a bash script like: #!/bin/bash echo Hello world! How do I execute
I have a bash script file which starts with a function definition, like this:
I'have a bash script calling a jar file like this: awk -f fileformat.awk list.txt
Currently I have a bash script which runs the find command, like so: find
Let's say I have a Bash script called foo.sh . I'd like to call

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.