kill - Send a specified signal to a process or process group.

learn more… | top users | synonyms

5
votes
3answers
386 views

Using `kill -s 0 $pid` vs `[[ -e /proc/$pid ]]` to detect if PID is running

One of the idioms often used to check if process is running is to use kill -s 0 $pid. My question is, does it have any upsides over using [[ -e /proc/$pid ]] construct? The script I'm writing is ...
1
vote
2answers
70 views

"trap 'killall $$ ; rm -f $folder2;exit ' 18 20 24

What is wrong with this command? $ trap 'killall $$ ; rm -f $folder2;exit ' 18 20 24 That command is in a for loop, and while that for is executing, if I press CTRL-Z I want it to stop the process ...
1
vote
2answers
252 views

xargs inside a for loop

So we got most of it figured out but here's what happens. for i in $(arp |sort |awk '{print $1}'|grep IPADDRESS) do ssh USERNAME@$i "ps -ef |grep X11|grep -v grep |awk '{print $2}'|xargs kill" done ...
9
votes
3answers
3k views

Default exit code when process is terminated?

When a process is killed with a handle-able signal like SIGINT or SIGTERM but it does not handle the signal, what will be the exit code of the process? What about for unhandle-able signals like ...
0
votes
2answers
208 views

Kill a nohup mpi process

I have started a program in parallel using the command: nohup mpirun -7 mylongprogram.py & I now want to terminate the program. When I want to kill the process by the command: kill -9 ...
2
votes
0answers
36 views

Reason for the inability of root to send a fatal signal to PID 1/init [duplicate]

Why can't root send a fatal signal to PID 1/init process (sudo kill -9 1)? As stated here.
2
votes
2answers
2k 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
3answers
3k views

process id and killing process - ps commmand

Please see the output of below ps command: abc@smaug:~/Desktop$ ps ax | grep firefox 2213 ? Sl 2:01 /usr/lib/firefox/firefox 2644 pts/0 S+ 0:00 grep --color=auto firefox Please ...
1
vote
1answer
236 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
276 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
245 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 ...
1
vote
0answers
93 views

cabal dies on NixOS in KVM

I set up a NixOS system on KVM and installed the haskelPlatform package. Everything works fine, ghci works fine, but cabal dies without any helpful error message: [michas@nix:~]$ type -a cabal cabal ...
11
votes
2answers
1k views

Does `kill -p` really work?

In the man page of kill it is written as following SYNOPSIS kill [ -s signal | -p ] [ -a ] [ -- ] pid ... kill -l [ signal ] -p Specify that kill should only print the process id ...
8
votes
3answers
1k views

What's the difference between pkill and killall?

I know that pkill has more filtering rules than killall. My question is, what is the difference between: pkill [signal] name and killall [signal] name I've read that killall is more effective ...
1
vote
2answers
878 views

How can I automatically kill the process with the highest CPU load?

Sometimes programs will lock up in the background and cause high CPU usage. Is there any way I can programmatically ascertain which process is causing the highest CPU load at the moment and kill it?
0
votes
2answers
4k views

How to kill a process that says “Operation not permitted” when attempted?

I have a process I would like to kill: computer@ubuntu:~$ ps aux | grep socat root 2092 0.0 0.0 5564 1528 pts/1 T 14:37 0:00 sudo socat TCP:xxx.17.29.152:54321 ...
2
votes
3answers
419 views

Rotating logs generated from tcpdump with logrotate

On one production linux box, I am capturing SIP packets using the following configuration: logrotate.conf: # Opensips SIP traces /var/log/sip.log { rotate 31 daily missingok ...
1
vote
1answer
91 views

How to list killable tasks?

As manpage of ps states A process with STATUS with the value "D" means "uninterruptible sleep (usually IO)" Also, I've read: You should use TASK_INTERRUPTIBLE here, otherwise your kernel thread ...
2
votes
5answers
818 views

Get return value of process by PID

If I have the PID of a process that was killed, how might I get the return status of the process? I am particularly interested to know if the return status was 143 (kill) or 137 (kill -9) as I don't ...
2
votes
1answer
184 views

kill all process of executables in a folder

I need to kill all the child process. The main process in lmbench pkill -9 lmbench is not killing it, but kill -9 <pid> kills the parent process, but even after killing the parent ...
1
vote
2answers
249 views

How to kill a script which starts new processes?

The following is a Python application which spans a few threads, then spawns a new process of itself and exits: $ cat restart.py import os import random import signal import sys import threading ...
4
votes
1answer
100 views

Stop a task based on output

I have a task that runs written in Mono, however sometimes (randomly) the Mono runtime will hang after the task is complete and just print: _wapi_handle_ref: Attempting to ref unused handle 0x2828 ...
3
votes
3answers
390 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 ...
0
votes
1answer
102 views

pkill process containing special characters

trying to run pkill on file with "+" in the name pkill -SIGTERM -f "auth+live+ec575698789349860987088t897906769878968970" if i take out this part "auth+live+" I am successful I've tried putting it ...
4
votes
1answer
99 views

how to list all instances of an application?

How do I list all instances of an application. ie I am running 12 instances of application called "tcpA" I would like to list all of them. Below is top, I don't know if there is a way to look at a ...
2
votes
4answers
2k views

How to kill a process which can't be killed without rebooting?

There are 5 processes which can't be killed by kill -9 $PID and executing cat /proc/$PID/cmdline will hang the current session. Maybe they're zombie processes. Executing ps -ef or htop will also hang ...
5
votes
2answers
464 views

My process was killed but I cannot understand the kernel notice

I have a custom application running on an embedded x86 setup (built using buildroot and uClibc). The application has been running fine but this morning when I returned to work I discovered my process ...
7
votes
1answer
327 views

How signals work internally?

In general, to kill processes we generate signals like SIGKILL,SIGTSTP etc. But how is it known who ordered that particular signal, who has sent it to a particular process, and in general how do ...
4
votes
3answers
4k views

Terminating a bash shell script running in the background

I often use bash shell scripts to run simple commands for many different files. For example, suppose that I have the following bash shell script, called script.sh, that runs the program/command foo ...
2
votes
2answers
704 views

Closing all Nautilus windows from terminal

How can I close all opened Nautilus (explorer) windows from the terminal?
1
vote
2answers
614 views

How do I kill 'repo sync' using crontab given it spawns many processes?

I need to 'repo sync' the Android source overnight, as my monthly bandwidth is limited. , I start the 'repo sync' at midnight, then want to kill it at 8am. The following is the command: 2 0 * * * ...
1
vote
1answer
199 views

How to kill all processes that don't have specific parent process?

A parent process should always be running with N children process. I would like to run a script which will show/kill all children processes that don't have a parent process. $ ps faux | grep ...
0
votes
2answers
1k views

`ps | grep | kill` aborts my script prematurely [duplicate]

I have a Linux computer that I remotely SSH into using plink on a Windows XP machine. I have the Plink program set to execute commands in a script using automated login: plink -ssh [domain name] -l ...
3
votes
3answers
324 views

Print process ID (PID) of a Matlab instance

To run my Matlab scripts, I've created a shell script to which I give two parameters - the path to the matlab file ($1) and to the log file ($2): nohup time matlab -some_parameters -r "run $1;exit" ...
1
vote
1answer
821 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 ...
2
votes
1answer
651 views

Why is brk(0) called?

On a first shell I run the command tail with no argument. On a second shell I kill the first tail using strace to monitor the system calls. qdii@nomada ~ $ strace kill 1713 execve("/bin/kill", ...
1
vote
2answers
300 views

How to safely kill processes so that output redirection is not aborted?

I'm writing some automation scripts, in which I need to kill some processes. Previously I would usually use kill -9 pid to kill processes but once upon a time, I notice that when I used kill -9 to ...
1
vote
2answers
81 views

How can I kill gnome shell widgets?

I have some gnome shell widgets that I need to be closed. I am unable to find which processes are behind them. Any idea how can I kill them?
2
votes
3answers
2k views

pkill can't kill processes with parent process id 1

I want to kill the following processes using pkill "run_tcp_sender.sh" or pkill -SIGKILL "run_tcp_sender.sh" root 14320 1 0 2012 ? 00:00:00 bash run_tcp_sender.sh ...
6
votes
2answers
205 views

Decode Flags for Kill Command

I am new to Shell Scripting. I saw this Command on a Book for Linux shell Scripting $ kill -HUP 1234 >killout.txt 2>killerr.txt I know what the command does, but i am not able to understand ...
4
votes
1answer
44 views

Suspend and edit previous single line commands

Say I want to modify the latter of some concatenated command line options, is it possible without killing the first command? Specifically I have compile and run scripts executed thusly: > compile ...
7
votes
2answers
429 views

Kill user processess on logout

I have a Ubuntu server that handles remote X sessions from users. However, I don't want to allow users to run any kind of background processes - so here is my question: How do I prevent users from ...
0
votes
2answers
200 views

Unix command to exit from command prompt

How can I exit from command prompt from shell file? shell file contains : if(); then // some unix code here else // want to exit from cmd prompt or Kill current cmd prompt fi can any knows @ it?
3
votes
1answer
256 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
2answers
361 views

Why is `kill -s INT <zsh PID>` behaving differently from `Ctrl-C`?

Starting with: % donothing () { echo $$; sleep 1000000 } % donothing 47139 If at this point I hit Ctrl-C at the same terminal that is controlling the shell, then the function donothing does indeed ...
3
votes
5answers
3k views

kill a group of processes with negative PID

kill -TERM -PID is supposed to kill PID and all its child processes. but this doesn't work on openSUSE, it always tell me that no such process -PID no matter what PID i use. So if the negative PID ...
2
votes
1answer
101 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 ...
3
votes
1answer
3k views

What does kill 0 do actually?

In the man page, it says: kill [ -s signal | -p ] [ -a ] [ -- ] pid ... pid... Specify the list of processes that kill should signal. Each pid can be one of five things: 0 All ...
19
votes
1answer
1k views

How does systemd survive a kill -9?

Between the recent "Why does 'kill -9 0' end my console session" and "How to get a kernel panic" questions, I got a bur under my saddle and tried kill -9 1 on a mostly up-to-date Arch linux laptop. I ...
7
votes
1answer
511 views

Why does “kill -9 0” end my console session?

I just wonder why kill -9 0 ends my tty console session? What exactly is PID 0, it is not listed on a ps aux?