2
votes
1answer
484 views

Why is 'kill -9' killing browser as well as server?

I sometimes have to use kill -9 as a last resort to kill my rails server. Unfortunately, I have to do that often enough that I wrote a helper function in my bash_profile to do it. If I do it manually ...
2
votes
1answer
112 views

how to execute more than one command gnome-terminal

I have a script which is running some of (more than 15) applications like: cd mypath sleep 1 gnome-terminal -t App1 --tab -e "./App1" sleep 1 gnome-terminal -t App2 --tab -e "./App2" .. .. sleep ...
1
vote
1answer
49 views

getting pid of two last commands executed in background and do stuff

I wrote this bash: #!/bin/bash eval "(a command) &" pid1=$! eval "(while kill -0 $pid1; do .... ; done) &" #It creates file.txt after few seconds pid2=$! if [ -s ...
3
votes
5answers
924 views

Getting pid of bash script from itself

I have a bash script with doing lot of things called script.sh: #!/bin/bash #It #Is #Doing #Things Is there a way that I be able to get the proccess of script and then kill it after 5 minutes? ...
2
votes
2answers
181 views

Killing background process in bash script when exiting the script

I have a script that tail a file while displaying a clock in the top right corner. I took the clock part from the internet, and it works ok. The entire script is something like (I simplified): while ...
4
votes
3answers
73 views

How to send SIGKILLs to entire pipeline?

while true; do # process substitution instead of usual pipeline to avoid waiting for all programs handle_input_with_timeout < <( prog1 | prog2 | prog3 ) echo "Data stopped flowing. ...
2
votes
2answers
159 views

Bash script to signal a concurrently running instance (same script) about a condition and increment counter

Background Here's what I want to achieve. I have a (potentially) long-running process. Now I have locking in place just fine and all is generally in order. However, since this is a scheduled job, ...
3
votes
1answer
265 views

How does the piping in this command ultimately achieve to kill the process?

I have seen the following line in a bash script for killing a process(in this case started with the command loadgen): ps xww | grep -i "loadgen" | grep "PATTERNMATCH_FACT.xml" | cut -c1-5 | xargs -i ...
2
votes
2answers
3k views

How do I kill all screens?

I accidentally created over 1000 screens. How do I kill them all with one command? (Or a few)
1
vote
1answer
328 views

Script ends abruptly with a Terminated message

This is my bash script. All it does is to check whether a service has started and whether some processes are running as expected. It ends abruptly with a Terminated message. I tried debugging it ...
1
vote
1answer
333 views

How to create alias to kill processes running on a TCP/IP port? [duplicate]

What I have: alias killport='sudo kill -9 `sudo fuser -n tcp $1 2> /dev/null`' Problem: Running e.g. killport 8000 doesn't appear to work, though. However, simply running... sudo kill -9 `sudo ...
0
votes
2answers
326 views

Pass flags to xargs

I want to kill a bunch of processes using this command: sudo ps ax | grep node | awk '{print $1}' | xargs kill But it gives me operation not permitted even with sudo. Then I tried with kill -9 ...
3
votes
3answers
459 views

timeout without killing process in bash

I have a main script that I'm running, and from it I have a second "slow process" I want to kick off, and "do something" in the main script if it doesn't complete in the time limit -- depending on if ...
1
vote
1answer
1k views

How to kill the (last - 1) PID with bash

I know how to kill the last process with kill $! However I would like to kill the last−1 process, i.e. not the last one, but the one before the last one. I tried kill $$(($! -1)) but ...
3
votes
1answer
280 views

bash: different output between CTRL-C vs “ordered cleanup”

I really tried to find a better title for this question. I am open for suggestions. I've written a bash script that traps EXIT and calls a function if that signal is received. It calls the same ...
2
votes
1answer
104 views

Chain commands with Control + C interrupt

I am trying to execute a program which loops indefinitely, and so must be forcibly interrupted. After executing the program, I want to delete it. I can do it in several steps: ./MyProg Control + C ...
13
votes
2answers
2k views

Why does bash show 'Terminated' after killing a process?

Here is the behaviour I want to understand: $ ps PID TTY TIME CMD 392 ttys000 0:00.20 -bash 4268 ttys000 0:00.00 xargs $ kill 4268 $ ps PID TTY TIME CMD 392 ttys000 ...
0
votes
2answers
2k views

Sending SIGUSR1 to parent

When I do a kill -SIGUSR1 $PPID I get kill: (1) - Operation not permitted . How can I overcome this?
2
votes
1answer
135 views

Refreshing less on the fly

I'm writing a script in which I pass the output of a function to less, wait for some time, and then kill less. All of this done inside a loop. This makes it look like less is updated on the fly. ...
5
votes
4answers
386 views

Accidental `nano SomeFile | uniq` renders the shell unresponsive

In my attempt to get unique entries (read lines) out of a simple text file, I accidentally executed nano SomeTextFile | uniq. This "instruction" renders the shell (bash) completely (?) ...
2
votes
2answers
849 views

Why can't I kill a timeout called from a Bash script with a keystroke?

[Edit: This looks similar to some other questions asking how to kill all spawned processes – the answers all seem to be to use pkill. So the core of my question may be: Is there a way to propagate ...
9
votes
4answers
5k views

How can I kill and wait for background processes to finish in a shell script when I Ctrl+C it?

I'm trying to set up a shell script so that it runs background processes, and when I Ctrlc the shell script, it kills the children, then exits. The best that I've managed to come up with is this. It ...
1
vote
1answer
327 views

How to create a cron which finds/kills/clears old puppet runs?

I am a new user of bash/cron, and I was given a task to create a cron which finds/kill/ and clears old puppet runs that were not successfully installed. The more help the better, but I am more or less ...
16
votes
5answers
8k views

How can I close a terminal without killing its children (without running `screen` first)?

sometimes I run an app in the gnome-terminal, but then I suddenly have to restart gnome or something. I guess the answer to the question is also useful then I want to disconnect from SSH where ...