I have a folder that is filled with .pid files. Each has the PID for a resque worker. How can I kill every PID in that folder from the command line?
cat folder/*.pid | xargs kill
should do it?
If you need to specify a signal, for example KILL
, then
cat folder/*.pid | xargs kill -KILL
If your pidfiles lack newlines, this may work better:
( cd folder &&
for pidfile in *.pid; do echo kill -QUIT `cat $pidfile`; done
)
According to the docs it says to use:
ps -e -o pid,command | grep [r]esque-[0-9] | cut -d ' ' -f 1 | xargs -L1 kill -s QUIT
Note: That looks them up by name instead of using the .pid
files.
Also, the QUIT
signal will gracefully kill them. If you want to forcefully kill them use TERM
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With