2
votes
1answer
47 views

Kill any service running at a specific port

I am trying to write a script that kills service running at a specific port. This is my script: a=$(ps ax | grep 4990 | grep java | awk '{print $1}') kill -9 $a It's a java program. This script ...
1
vote
1answer
27 views

killall <processname> throughout the system [closed]

I'm opening two terminal windows. Terminal 1 - I run process1 Terminal 2 - I run process2 I then terminate both process using Ctrl+Z in each window. I type killall -9 process1 in Terminal 2 , ...
1
vote
1answer
67 views

kill pid is not working? [duplicate]

This is pretty weird now. I am trying to kill a process by using its pid but it is not working at all. root@machineA:/home/david# ps aux | grep modelling david 5075 0.0 0.0 1285420 29404 ? ...
1
vote
1answer
34 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
243 views

Run a process to particular/dedicated pid only

I have a c program executable or shell script which I want to run very often. If I want to stop/pause or to notify something I will send signal to that process. So every time I have to check the pid ...
3
votes
5answers
603 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? ...
0
votes
1answer
134 views

Directory locked! [closed]

I have been trying to install virtualbox using this command: sudo apt-get install virtualbox.qt But I am getting this error: E: Unable to lock directory /var/cache/apt/archives/ I have been ...
6
votes
5answers
2k views

Kill all descendant processes [duplicate]

I'm writing an application. It has the ability to spawn various external processes. When the application closes, I want any processes it has spawned to be killed. Sounds easy enough, right? Look up ...
0
votes
1answer
65 views

Can a script be running even after it's been killed?

I know it sounds so stupid and I know it IS stupid but I ran a unix script to send me and my friend emails every few seconds to test mailx. Stupid thing is I used $ while true; do blah blah blah... ...
0
votes
2answers
71 views

Why does kill not have a parameter for file and not for port number?

If I want to stop a program given its tcp port number or its file or named executable, can I run something like kill -tcpPortNumber $1 where the parameter $1 is a tcp port number or kill -filename $1 ...
68
votes
2answers
5k views

How does Linux “kill” a process?

It often baffles me that although I have been working professionally with computers for several decades, and Linux for a decade, I actually treat most of the OS' functionality as a black box, not ...
5
votes
2answers
240 views

Processes do not respond to my signals

I have a strange behavior on my system. When I invoke a command in the shell (bash version 4.2.45(1)-release), say top or cat, the running program (the process) does not respond to Ctrl+C. I even ...
33
votes
6answers
4k views

Does pressing ctrl-c several times make the running program close more quickly?

I often start to read a huge file and then want to quit after a while, but there is a lag from pressing Ctrl+C to the program stops. Is there a chance of shortening the lag by pressing the Ctrl+C key ...
3
votes
1answer
177 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 ...
8
votes
2answers
271 views

How can I create a hard to kill process

I want to create a program that will be difficult to stop (even for the administrator) once it is started (with root privileges). Once started the process should continue to start itself at startup ...
12
votes
3answers
8k views

How to stop a background process?

I have started a wget on remote machine in background using &. Suddenly it stops downloading. I want to stop its process, then start it again. How can I stop it? I haven't close its shell window. ...
0
votes
3answers
947 views

Cannot kill teamviewer process

My main desktop has Mint 14 and I approached it via SSH from another computer, because I didn't have a screen on the Mint one. Then I tried to start teamviewer just I order to launch its desktop ...
5
votes
3answers
337 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
3answers
2k 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 ...
7
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
789 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?
1
vote
1answer
84 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
735 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 ...
1
vote
2answers
226 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 ...
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 ...
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 ...
1
vote
2answers
594 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
191 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
999 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
303 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
760 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
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 ...
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
398 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 ...
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 ...
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
489 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?
12
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 ...
1
vote
3answers
5k views

Kill only one Java process

I usually run few Java applications, one for server running locally and other for some IDE like NetBeans. And from time to time, after lots of redeployments, my server get stuck on ...
4
votes
1answer
496 views

What is the difference between exiting a process via Ctrl+C vs issuing a kill -9 command?

I know I can kill any process with kill -9 command . But sometimes i see that even if I have terminated a program with CTRL+C , the process doesn't get killed . So I want to know the difference ...
3
votes
1answer
1k views

Cannot kill a java process

I have a java process that cannot be killed. I have tried every method I know, or that I have found on the internet to no avail. I have tried: killall java kill -9 <pid> kill -11 <pid> ...
1
vote
1answer
176 views

Application in terminal still running but not directly accessible [duplicate]

Possible Duplicate: How to suspend and bring a background process to foreground I have kind of an odd problem which I haven't encountered before. Here's what I did: I started an ...
1
vote
3answers
809 views

I want to kill all processes that result from the following command

The following command will display all the PID's running for vmstat1: ps -ef | grep "vmstat 1" | awk '{ print $2 }' My question is, how do I kill them all, if there's like 20 of them at once?
1
vote
2answers
320 views

How to stop a infinite running process (ztail) started by a ssh session after that session is closed

I have a peculiar problem. My server supports multiple ssh session simultaneously, so that multiple admins can manage (via command line interface) it simultaneously. We have a command which calls ...
1
vote
1answer
399 views

Korn shell timeout/kill script

I am trying to write a simple Korn shell script to execute a loading process. The process occasionally runs into connectivity issues, so I need to kill it if it runs too long. I have been trying the ...
4
votes
2answers
177 views

How to kill a process giving it a number of seconds before a doing the forced kill?

I do have the PID of the process to be killed but I do want to give it the chance to die peacefully, without doing a -9. Expected behaviour: check if PID is still running for up to ten seconds and do ...
8
votes
6answers
5k views

Kill many instances of a running process with one command

This is one of the questions that has troubled me often. Suppose I have thousand or more instances of any process(for e.g. say the process vi) running. How do I kill them all in one single shot/one ...
2
votes
2answers
726 views

`[java] <defunct>` with defunct children -> Any way to collect them?

Relating to question : What if 'kill -9' doesn't work? I have following situation : zombie process with threads, not collected by init : [root@Arch64]# ps auxH | grep java gwpl 569 ...
4
votes
2answers
619 views

Why is `sudo pkill -HUP -f “nginx: master process”` returning code 129 and no output

I'm trying to trigger a reload of the Nginx master process by using pkill and sudo. The server reloads fine, but I was just curious if anyone knows why the command sudo pkill -HUP -f "nginx: master ...