Questions tagged [pkill]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
3 votes
1 answer
128 views

Execute multiple commands in one line through ssh starting with pkill -f

Noticed something strange while working with a raspberry pi. Using pkill with no options allows me to run other commands afterwards in the same line, but if I use the option -f, then subsequent ...
Marcelo's user avatar
  • 31
0 votes
0 answers
198 views

how to kill java process forcefully and remove directory which is used by that process

I have one use case where I am killing a java process with pkill java, and after that, I want to remove certain directories. I have used rm -rf /pathtofolder but it gives: rm: cannot remove '/...
Samurai's user avatar
  • 55
1 vote
1 answer
749 views

Linux using pkill to kill by process name for a specific user

I have a bash script where I run the pkill command to kill running processes. I have the username param defined as follows: username=$(whoami) I want to be able to kill processes based on the process ...
kasssia's user avatar
  • 13
4 votes
3 answers
2k views

Why are the signal lists for kill, killall and pkill not the same?

I researched the kill, pkill and killall commands, and I understood most of their differences. However, I am confused about their signals: If I run kill -l, I see: 1) SIGHUP 2) SIGINT 3) ...
Manuel Jordan's user avatar
1 vote
1 answer
1k views

What does Session ID mean within the pkill context?

About the pkill command, I know is possible kill processes - for specific scenarios - based through tty[1-6] and pts/[0-N]. I tested and works as expected. Until here all is ok. But now, according ...
Manuel Jordan's user avatar
1 vote
1 answer
129 views

When to use "pkill..." flag in newsyslog.conf?

I'm configuring relayd to log to its own log, and I'm not clear on whether I should run "pkill...". I can see the following in the default newsyslog.conf: # logfile_name owner:group ...
Paul's user avatar
  • 507
-2 votes
2 answers
305 views

pkill in server ubuntu

I used the command pkill as root on my vps ubuntu, and I got kicked out of the server and can't access it. This is what I wrote inside the terminal: pkill h h is my user in ubuntu What is the ...
Hassan's user avatar
  • 1
1 vote
1 answer
1k views

How to kill chrome under Linux so that it'll resume next time

How to kill chrome under Linux so that it'll resume/restore the sessions when it is started next time? It's a trivial thing to do under Windows, but under Linux, no matter how I tried to kill chrome, ...
xpt's user avatar
  • 1,354
4 votes
1 answer
3k views

Delete / Kill a process which won't die

I'm using Linux Ubuntu 20.04. I have a process with PID 21: PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 21 root 20 0 0 0 0 S 0.0 0.0 0:00....
Dean Van Greunen's user avatar
0 votes
2 answers
182 views

Is there a way to trigger the closing of one program by closing another? A shell script perhaps?

So, my situation is this: I have created a launcher, key bindings and an alias that opens GLava and CMus in a drop-down terminal at the same time, using this shell script: #!/bin/bash c=$(ps -e | ...
poutingcavity's user avatar
6 votes
4 answers
6k views

Is there a clean way to `sudo pkill` processes without including the `sudo` process?

I need to kill some processes that are run as sudo, matching them by full name, and count the number of original command invocations. For each process there are two processes: the command itself, and ...
Marcus's user avatar
  • 869
5 votes
0 answers
1k views

How do I send signal to all processes in a cgroup?

kill $(< /sys/fs/cgroup/freezer/<name>/tasks ) works, but looks clumsy, produces a warning if cgroup is empty and may hit command line length limit. pkill -F does not accept cgroup tasks file ...
Vi.'s user avatar
  • 5,618
1 vote
1 answer
418 views

Why does pkill not work with rofi?

I want to toggle rofi an application launcher with one keybinding. I made a shell script, #!/bin/bash rofi -dpi 1 -modi drun -show drun -show-icons And bound it to some key. This works but to toggle ...
scribe's user avatar
  • 123
0 votes
1 answer
4k views

How to kill the PID of service that configured as Restart=always

Dear friends and colleges , We have service under /etc/systemd/system Service name is calc_live_servers.service Since Restart=always is configured in calc_live_servers.service Then when we kill ...
user avatar
0 votes
1 answer
296 views

How to forcefully close a ssh connection is the command on the target server never returns

I have an automation tool that generates and executes the below command that fires rpm -qa grep httpd on the target host 10.9.100.67. ssh -vvv -o StrictHostKeyChecking=no -o 'IdentityFile="/app/...
Ashar's user avatar
  • 489
0 votes
0 answers
442 views

How to get cron to pkill my java process?

I have a cron job that runs to detect if a certain application has frozen. If so it should kill the frozen application and restart it. The application is a Java program. When the application is frozen,...
Patoshi パトシ's user avatar
3 votes
2 answers
2k views

would like to suppress the output of pkill on a background process

I have a shell-script in which I do an iostat -c 1 > data.cpu. & Later in the script, after I've collected the data I'm interested in, I do a pkill iostat which kills iostat and allows me ...
Richard Gostanian's user avatar
1 vote
1 answer
538 views

Why pkill return -9?

I want to run command pkill -9 -f 'java.*7104' in python3 use subprocess.run, but I do not know why returncode=-9, can anyone explain this? >>> subprocess.run("pkill -9 -f 'java.*7104'", ...
Ren's user avatar
  • 263
2 votes
1 answer
3k views

How to get pkill to output process information of killed process?

How to get pkill to output process information of killed process? I don't see anything in man pkill that suggests this is possible. I know I can do a pgrep and process the list and then pipe that to ...
Elijah Lynn's user avatar
0 votes
0 answers
30 views

Digital ocean server access issue

I have accidentally run command pkill -U root. I was in root user.. now I am not able to access through ssh from my local system but I can access my server's terminal on my browser from my digitl ...
Dexter's user avatar
  • 101
1 vote
1 answer
636 views

Tagging a process so I can kill it later easily by identifying

I need to tag a generic process (I don't really control the command being run). Could I do something like this: run_special_cmd(){ "$@" -- --very-special-command } run_special_cmd sleep 5000 &...
Alexander Mills's user avatar
1 vote
1 answer
3k views

pkill does not work on Ubuntu 16.04

I list all the processes in the system using ps -aux and I found this java process: 10253 2.1 10.1 3259172 398864 pts/0 Tl 06:58 0:09 java -jar /opt/can-peris/core-price-update/menu-core-...
en Peris's user avatar
  • 361
1 vote
1 answer
953 views

MacOS: su pkill -9 “process_name” = sorry

How to use pkill as su on a Mac? When I run su pkill -9 "RFBEventHelperd" in the terminal I get su: Sorry (but works as sudo). I am looking for a way to kill this process from inside a script that ...
Jsp's user avatar
  • 27
0 votes
3 answers
1k views

pkill -P variable not working when running .sh under cron

I have a very simple .sh script to kill a process. The processes saves its PID to pid2.txt. pkill -e -P $(cat pid2.txt) exit When I run this as sudo ./myscript.sh from the command line it works fine....
sjaak's user avatar
  • 574
0 votes
2 answers
2k views

Using `pgrep` to emulate `ps -ef` for use in a `for i in` loop

Ubuntu 16.04 I am used to using this command line to kill any process match said COMMAND for i in $(ps -ef | grep COMMAND | awk '{ print $2 }'); do kill -9 "$i" &>/dev/null;done shellcheck ...
Vituvo's user avatar
  • 411
6 votes
4 answers
7k views

How to stop a script within another script

I'm running Ubuntu 16.04, using a terminal emulator. I have two scripts: a.sh and b.sh.  a.sh calls b.sh. a.sh echo "a is running" sleep 5s bash b.sh sleep 5s echo "a is still running" b.sh echo "...
speld_rwong's user avatar
0 votes
1 answer
2k views

What is the `-KILL` option in `pkill` command

I have found a way to logout any user by using the command line. By executing the command pkill -KILL -u <username>, I can now log myself out from the session I have entered. My question is ...
Tower's user avatar
  • 479
1 vote
1 answer
55 views

Process is running [closed]

I have run the following command as root today morning sh /home/suio/LoadSnortSingature.sh > /home/suio/logs.txt 2>&1 after some time the session of the terminal closed and I have relogged in ...
chandu's user avatar
  • 191
3 votes
1 answer
18k views

How to force a PID to terminate? [duplicate]

Yes, I've tried all the basic kill, pkill, etc. methods that come up with a Google search. Sometimes it works, other times it seems something is preventing the process from terminating. There is no ...
voices's user avatar
  • 1,262
8 votes
1 answer
42k views

How to kill all processes owned by `user` on Centos 7? [duplicate]

I read in an online flash card that the command is: pkill -u bob $(pgrep -u bob) However, I think this is wrong. I think it's saying: Kill all the processed owned by bob, and 4572\n4600 Because: ...
mbigras's user avatar
  • 2,958
4 votes
2 answers
2k views

Kill process by name

I am using bash to start several instances of one python program, like this: python example.py -id $i where $i is the id given to the instance. All the processes are started on the same user, and ...
Jeroen Smulders's user avatar